I suspect that for some reason the window isn't being destroyed properly. I have done many simple windows programs like this in the past and I am not sure why this one all of a sudden is acting up on me. It keeps running in the background even when I close the window, and it uses %100 of my processor so everything else in windows runs really slow.
Code:#include <windows.h> LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ){ HWND Uber; MSG msg; WNDCLASSEX wc; wc.cbClsExtra = 0; wc.cbSize = sizeof(WNDCLASSEX); wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(hInstance, IDC_CROSS); wc.hIcon = LoadIcon(hInstance, IDI_ERROR); wc.hIconSm = NULL; wc.hInstance = hInstance; wc.lpfnWndProc = MainWndProc; wc.lpszClassName = "Main Window"; wc.lpszMenuName = "Main Window"; wc.style = CS_HREDRAW | CS_VREDRAW; if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Could not initialize window", "ERROR", MB_OK); return ERROR; } if(!(Uber = CreateWindowEx(NULL, "Main Window", "Main Window", WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL))) { MessageBox(NULL, "Could not initialize window", "ERROR", MB_OK); return ERROR; } ShowWindow(Uber, nShowCmd); UpdateWindow(Uber); while(GetMessage(&msg, Uber, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } }



LinkBack URL
About LinkBacks


