Advertisement

Windows Dialog box problem (still)

Started by June 28, 2000 07:09 PM
2 comments, last by Shadwdrak 24 years, 5 months ago
This message was posted below a few days ago. Since then I tried the suggested fixes as well as some other things, but to no avail. I now get an error that is almost the same as the other. Here''s the code: #include #include #include "resource.h" // Windows function prototypes LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); // Main window procedure BOOL CALLBACK AboutProc(HWND, UINT, WPARAM, LPARAM); // About box window procedure HWND hwnd; // Handle to the window /////////////////////////////////////// //// WINMAIN ////////////////////////// /////////////////////////////////////// int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("Map Editor"); MSG msg; WNDCLASS wndclass; wndclass.style = CS_HREDRAW / CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance, IDI_APPLICATION); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wndclass.lpszClassName = szAppName; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR); return 0; } hwnd = CreateWindow(szAppName, // class name; szAppName, // window name; WS_OVERLAPPEDWINDOW, // window style; CW_USEDEFAULT, CW_USEDEFAULT, // starting position (x,y); CW_USEDEFAULT, CW_USEDEFAULT, // width and height; NULL, // parent handle; NULL, // menu handle; hInstance, // instance handle; NULL); //pointer to window creation data ShowWindow (hwnd, iCmdShow); UpdateWindow (hwnd); while (TRUE) { if(PeekMessage (&msg, NULL, 0,0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage (&msg); DispatchMessage (&msg); } else { // This is the main game loop (DUH!!!) } } return msg.wParam; }; /////////////////////////////////////// //// WNDPROC ////////////////////////// /////////////////////////////////////// LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hInstance; switch (message) { case WM_CREATE: hInstance = ((LPCREATESTRUCT) lParam)->hInstance; return 0; case WM_KEYDOWN: switch (wParam) { case VK_ESCAPE: break; } return 0; case WM_MOUSEMOVE: return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_EXIT: PostQuitMessage(0); return 0; case ID_ABOUT: DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc); // instance handle return 0; } return 0; case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hwnd, message, wParam, lParam); }; ////////////////////////////// // PROGRAM ABOUT BOX ////////////////////////////// BOOL CALLBACK AboutProc(HWND hwndAbout, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: return true; } return FALSE; case WM_CLOSE: EndDialog(hwndAbout, IDOK); return TRUE; } return FALSE; } ****END OF CODE**** Here is the error: D:\Programming\Map Editor\Main.cpp(123) : error C2664: ''DialogBoxParamA'' : cannot convert parameter 4 from ''int (void *,unsigned int,unsigned int,long)'' to ''int (__stdcall *)(void)'' Its really quite annoying. I If you read the code above I already owe you thanks... so thanks. If ya have a clue as to the source of my problem, let me know. -Shadwdrak
I copied the code from your post (then removed that damn annoying spacing) and it compiles fine for me... From what I got from your post i can''t seem to see anything wrong...
Advertisement
Maybe add typecasting for your Dialog Proc:

    {DLGPROC)AboutProc    


YAY! Thanks alot baskuenen the typecasting worked! I can FINALLY get on with the program... Again thanks!

Thanks also to everyone who read my posts. I''ts nice to have a place to go with these questions.

-Shadwdrak

This topic is closed to new replies.

Advertisement