Archived

This topic is now archived and is closed to further replies.

da_cobra

can't get out of my dialog window

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites