Jump to content
  • Advertisement

Archived

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

da_cobra

can't get out of my dialog window

This topic is 6224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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

Share this post


Link to post
Share on other sites
when I do it like you say then the compiler gives me the following error :

error C2065: ''About'' : undeclared identifier

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!