Advertisement

Menu sometimes disappears

Started by March 08, 2003 10:55 PM
-1 comments, last by openback 21 years, 8 months ago
I''m just trying to make a basic program and for some reason I can get my program to have a menu one second, and then when i change the code slightly, in spots that have nothing to do with the menu, it simply never shows up when i recompile the program. I have yet to get it back. What can be going wrong? #include <windows.h> #include <windowsx.h> #include "resource.h" #define ID_APP_EXIT 0xE141 #define WIN_CLASS_1 "Window Class 1" LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); HWND initInstance(HWND hwnd, HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow); static void cls_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) ; static void cls_OnDestroy (HWND hwnd); int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HWND hwnd = NULL; MSG msg; hwnd = initInstance(hwnd, hInstance, szCmdLine, iCmdShow); if (hwnd == NULL) return EXIT_FAILURE; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } UnregisterClass( WIN_CLASS_1, hInstance); return msg.wParam; } LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch (iMsg) { HANDLE_MSG(hwnd,WM_COMMAND,cls_OnCommand); HANDLE_MSG(hwnd,WM_CLOSE, cls_OnDestroy); HANDLE_MSG(hwnd,WM_DESTROY,cls_OnDestroy); } return DefWindowProc (hwnd, iMsg, wParam, lParam); } HWND initInstance(HWND hwnd, HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow) { WNDCLASSEX wndclass; wndclass.cbSize = sizeof (wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON),0); wndclass.hIconSm = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0); wndclass.hCursor = (HCURSOR)LoadImage(hInstance,MAKEINTRESOURCE(IDC_POINTER),IMAGE_CURSOR,0,0,LR_DEFAULTSIZE); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wndclass.lpszMenuName = "my_menu"; wndclass.lpszClassName = WIN_CLASS_1; RegisterClassEx (&wndclass); hwnd = CreateWindow( WIN_CLASS_1, "openback:ixelpod INTERNATIONAL::", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, // width 300, // height NULL, // parent window handle NULL, // window menu handle hInstance, NULL); if (!hwnd) return NULL; ShowWindow (hwnd, iCmdShow); UpdateWindow (hwnd); return hwnd; } static void cls_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch (id) { case ID_APP_EXIT: PostQuitMessage(0); break; default: FORWARD_WM_COMMAND (hwnd, id, hwndCtl, codeNotify, DefWindowProc) ; }; } static void cls_OnDestroy (HWND hwnd) { PostQuitMessage (0) ; }

This topic is closed to new replies.

Advertisement