Some help with C++

Discussion about hacker.org's server
Post Reply
Liidian
Posts: 202
Joined: Fri Jun 05, 2009 10:49 pm
Location: Guess

Some help with C++

Post by Liidian »

Rarely turn to this site for help but i've stumbled upon the issue that when i try to use the standard GUI form it seems to just shut down Dev C++ without saving progress. I don't get any error logs, and of course i've tried reinstalling the software. I'm not really sure whats wrong. Im' guessing the problem is somewhere within compiling the program hence it will shut down while doing so.

Any idea's on this issue? I'm 99% it's NOT a virus infection sence by several reasons it would be very unlikely for me to get infected.

Again i excuse myself for grammatical or spelling mistakes i might have done. Thank you for taking your time reading this and please try contacting me regarding the issue if you do have any clue what is wrong.

Thank you.

Code: Select all

#include <windows.h>
	 
	LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
	 
	static char sClassName[]  = "MyClass";
	static HINSTANCE zhInstance = NULL;
	 
	int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	        WNDCLASSEX WndClass;
	        HWND hwnd;
	        MSG Msg;
	 
	        zhInstance = hInstance;
	 
	        WndClass.cbSize        = sizeof(WNDCLASSEX);
	        WndClass.style         = NULL;
	        WndClass.lpfnWndProc   = WndProc;
	        WndClass.cbClsExtra    = 0;
	        WndClass.cbWndExtra    = 0;
	        WndClass.hInstance     = zhInstance;
	        WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
	        WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	        WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	        WndClass.lpszMenuName  = NULL;
	        WndClass.lpszClassName = sClassName;
	        WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
 
	        if(!RegisterClassEx(&WndClass)) {
	                MessageBox(0, "Error Registering Class!", "Error!", MB_ICONSTOP | MB_OK);
	                return 0;
	        }
	 
	        hwnd = CreateWindowEx(WS_EX_STATICEDGE, sClassName, "db Tutorial", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
	 
	CW_USEDEFAULT,
	                     320, 240, NULL, NULL, zhInstance, NULL);
	 
	        if(hwnd == NULL) {
	                MessageBox(0, "Error Creating Window!", "Error!", MB_ICONSTOP | MB_OK);
	                return 0;
	        }
	 
	        ShowWindow(hwnd, nCmdShow);
	        UpdateWindow(hwnd);
	 
	        while(GetMessage(&Msg, NULL, 0, 0)) {
	                TranslateMessage(&Msg);
	                DispatchMessage(&Msg);
	        }
	 
	        return Msg.wParam;
	}
	 
	LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
	        switch(Message) {
	                case WM_CLOSE:
	                        DestroyWindow(hwnd);
	                        break;
	                case WM_DESTROY:
	                        PostQuitMessage(0);
	                        break;
	                default:
	                        return DefWindowProc(hwnd, Message, wParam, lParam);
	        }
	        return 0;
	}
User avatar
CodeX
Posts: 350
Joined: Fri Oct 17, 2008 5:28 pm

Post by CodeX »

I guess you are using the rather old 2005 release from bloodshed.net, which is supposedly a bit buggy + was made for XP which isn't going to help it's stability on something like Windows 7. I would recommend getting the latest version of it from here or switching to something else such as Code::Blocks. The best I could suggest otherwise is running it in compatibility mode with admin privileges.
Post Reply