can't get out of my dialog window

Started by
3 comments, last by da_cobra 22 years, 5 months ago
I just created a simple window with a Exit and an About box in vc++ The exit works fine, my program exits normally but when I press About, my about dialog appears, but then I can''t exit it, my dialog box has a OK-button and a "X" to close it but that doesn''t work, I know that I should create a msghandler for my dialogbox and then call it with this function : DialogBox(GetModuleHandle(NULL), (LPCTSTR)IDD_DIALOG1, hwnd, NULL); but this doesn''t work (by the way I replaced that last parameter with NULL, because my compiler keeps giving me errors when I try to put "About" there (about is the handle to my about-box message loop) what else am I doing wrong LRESULT CALLBACK MsgHandler( HWND hwnd, // This is the handle of the window that sent the message // currently being precessed. UINT msg, // The message identifier WPARAM wparam, // The exact use of the these parameters depends on which LPARAM lparam) // message is being sent, but they are used to further { switch(msg) { case WM_CREATE: // window created { return 0 ; } break ; case WM_COMMAND: // menu command { switch(LOWORD(wparam)) { case ID_APP_EXIT: { PostMessage(hwnd, WM_CLOSE, 0, 0) ; } break ; case ID_APP_ABOUT: { DialogBox(GetModuleHandle(NULL), (LPCTSTR)IDD_DIALOG1, hwnd, NULL); } break ; } } break ; case WM_CLOSE: // User presses close-button or ALT-F4 { // perfect spot to do cleanup checks DestroyWindow(hwnd) ; // Destroys our child-windows (sends out WM_DESTROY) PostMessage(hwnd, WM_DESTROY, 0, 0) ; } // and then our main window break ; case WM_DESTROY: // exit program { PostQuitMessage(0) ; // exit program return 0 ; } break ; } return(DefWindowProc(hwnd, msg, wparam, lparam)) ; // Default message handler } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; } thanx in advance for any help
Advertisement
ialogBox(GetModuleHandle(NULL), (LPCTSTR)IDD_DIALOG1, hwnd, (DLGPROC)About);

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T
and does it matter where in my source I put that message loop for the dialog box?

again thanx in advance!!!
when I do it like you say then the compiler gives me the following error :

error C2065: ''About'' : undeclared identifier
I think it is always good practice to prototype your functions at the top of your file so that you can have them in any order you want without the compiler telling you it doesn''t know what function X is.

Invader X
Invader''s Realm

This topic is closed to new replies.

Advertisement