Hi its took me a while to realise but once my windows program has finished it does not release the resources it has been using. If I press control alt delete and then go to processes I find my application that should of been terminated using 98% of the resources and I was wondering why?
Ps. For some reason my cursor is not changing when the user asks for a different cursor on the menu bar. I have been told that the SetCursor function has to be maintained by yourself but I don't know how to do this. If someone could help with this too it would be very greatful.Code:// This Program is designed to incorporate defining a windows class // Creating a window a message handler using custom icons, cursors // Also a choice of music files made possible by a message system #include <windows.h> #include <windowsx.h> #include "RESOURCES.H" HINSTANCE theInstance; LRESULT CALLBACK messageHandler (HWND theWin, UINT theMsg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch (theMsg) { case WM_CREATE: { return 0; break; } case WM_PAINT: { hdc = BeginPaint(theWin,&ps); EndPaint(theWin,&ps); return 0; break; } case WM_DESTROY: { PlaySound(NULL,theInstance,SND_PURGE); PostQuitMessage(0); break; return 0; } case WM_COMMAND: { switch (LOWORD(wparam)) { case MENU_FILE_ID3: { PostQuitMessage(0); return 0; break; } case MENU_CURSOR_ID1: { HCURSOR theCursor; theCursor = LoadCursor(theInstance, MAKEINTRESOURCE(CURSOR_ID1)); SetCursor(theCursor); return 0; break; } case MENU_CURSOR_ID2: { HCURSOR theCursor; theCursor = LoadCursor(theInstance, MAKEINTRESOURCE(CURSOR_ID2)); SetCursor(theCursor); return 0; break; } case MENU_CURSOR_ID3: { HCURSOR theCursor; theCursor = LoadCursor(theInstance, MAKEINTRESOURCE(CURSOR_ID3)); SetCursor(theCursor); return 0; break; } case MENU_SONG_ID1: { PlaySound(MAKEINTRESOURCE(WAVE_ID1), theInstance, SND_RESOURCE | SND_LOOP | SND_ASYNC); return 0; break; } case MENU_SONG_ID2: { PlaySound(MAKEINTRESOURCE(WAVE_ID2), theInstance, SND_RESOURCE | SND_LOOP | SND_ASYNC); return 0; break; } case MENU_SONG_ID3: { PlaySound(MAKEINTRESOURCE(WAVE_ID3), theInstance, SND_RESOURCE | SND_LOOP | SND_ASYNC); return 0; break; } default: { break; } } } default: { break; } } return (DefWindowProc(theWin,theMsg,wparam,lparam)); } int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCmd) { theInstance = hInstance; MSG theMsg; HWND WindowsHandle; WNDCLASSEX winclass; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.lpfnWndProc = messageHandler; winclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ID1)); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winclass.lpszMenuName = "MainMenu"; winclass.lpszClassName = "windowClass"; winclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ID1)); if (!(RegisterClassEx(&winclass))) return 0; if (!(WindowsHandle = CreateWindowEx(NULL, "windowClass", "The Big One Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0,0, 400, 400, NULL, NULL, hInstance, NULL))) return 0; while (1) { if (PeekMessage(&theMsg,WindowsHandle, 0, 0, PM_REMOVE)) { if (theMsg.message == WM_QUIT) break; TranslateMessage(&theMsg); DispatchMessage(&theMsg); } } return 0; }



LinkBack URL
About LinkBacks


