From: MisterE <Mis...@zo...> - 2003-01-02 13:12:19
|
Hello dev-cpp-users, i have a question, probably very simple. I'm a delphi programmer, but now i have discovered Dev-C++ i'm spending some time with c++. So i've downloaded "the Forger's api tutorial" (http://www.winprog.org/tutorial/index.html) and some tutorials: www.cprogramming.com Now the question :) i'm trying to create the "forger's" examples with dev-c++ (because msvc++ is much to confusing with all those wizards) the "simple_window" and "window_click" did work fine. I'm now working on the chapter "Menus and Icons" but dev-C++ does not want to compile it. i succeeded to create a window with a menu, but now want it to do something when the user pressing a item. I thought i typed something wrong but i have tried to compile the original example (with import msvc project) but dev-C++ refuse to compile it. i've included to original example (from theForger) Hope someone can help me... Thanks in advance! The errors are: C:\Temp\menu_two\menu_two.c [Warning] In function `LRESULT WndProc(HWND__*, unsigned int, unsigned int,: 29 C:\Temp\menu_two\menu_two.c invalid conversion from `void*' to `HICON__*' 35 C:\Temp\menu_two\menu_two.c invalid conversion from `void*' to `HICON__*' C:\Temp\menu_two\Makefile.win [Build Error] [menu_two.o] Error 1 in case that attachments are 'stripped' #include <windows.h> #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 const char g_szClassName[] = "myWindowClass"; LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_CREATE: { HMENU hMenu, hSubMenu; HICON hIcon, hIconSm; hMenu = CreateMenu(); hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File"); hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Go"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Stuff"); SetMenu(hwnd, hMenu); hIcon = LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE); if(hIcon) SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); else MessageBox(hwnd, "Could not load large icon!", "Error", MB_OK | MB_ICONERROR); hIconSm = LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE); if(hIconSm) SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm); else MessageBox(hwnd, "Could not load small icon!", "Error", MB_OK | MB_ICONERROR); } break; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case ID_STUFF_GO: MessageBox(hwnd, "You clicked Go!", "Woo!", MB_OK); break; } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = NULL; if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "A Menu #2", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } -- Best regards, MisterE mailto:Mis...@zo... |