Jump to content
  • Advertisement
Sign in to follow this  
FlyHigh

Windows Dialogs + Messages

This topic is 4456 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

Hi Everybody, I've recently moved onto the windows gui side of a project i am doing and is going well however the more dialog boxes I add the more problems I get and its time to sort them out. I have an application which when loaded loads all the DLL's in its directory and allows them to register an item in a menu, on clicking the menu the appropriate DLL is called with the identifier of the menu item. So I have:
void MenuSelected(int MenuOffset)
{
    if(MenuOffset == 0) 
        DialogBox((HINSTANCE)DLLhMod, MAKEINTRESOURCE(IDD_DIALOG1), Apphwnd,
             (DLGPROC) Dialog1Proc)
}


RESULT CALLBACK Dialog1Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_INITDIALOG: return TRUE;
        case WM_COMMAND: 
            switch(LOWORD(wParam))
            {
                case IDOK:
                    if(!ValidateCombinations())
                    {    
                        MessageBox(hwnd,"Invalid Combination","!",MB_OK);
                        return TRUE;
                    } else {
                        EndDialog(hwnd,ID_OK);
                        return TRUE;
                    }
            }
            break;
        default: return DefWindowProc(hwnd,msg,wParam,lParam);
    }
}
The problem is that when the I click the menu item the code is correctly called and the dialog does display however it lacks a caption and is unmovable which is annoying, and also when I click ok on the dialog and make a message box appear it doesn't show unless i press the alt key and even then remains unresponsive, pressing alt-f4 here just closes the dialog and not the application and still leaves the messagebox. I used style - overlapped overlapped window - false clip children - false chilp siblings - fales border - dialog frame on the form properties if that helps. If you need any more information just ask.

Share this post


Link to post
Share on other sites
Advertisement
Dialogs don't call DefWindowProc - they just return TRUE or FALSE. Your Dialog1Proc looks a bit suspect to me. It should be:

BOOL CALLBACK Dialog1Proc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
See DialogProc in the MSDN.


This is why you never ever ever cast function pointers, it's akin to doing printf((const char*)42); and wondering why it doesn't work [wink]

Share this post


Link to post
Share on other sites
Sign in to follow this  

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