Jump to content
  • Advertisement
Sign in to follow this  
nitzan

redrawing scene while DialogBox is open

This topic is 5053 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 am working on a level editor, and when the user clicks on an object, I want a dialog box to open with modifable object stats, and I want to see the object change in the OpenGL/D3D window as I change the stats in the dialog box. I can get the Dialog Box to open no problem, but the OpenGL/D3D window stops responding. According to MSDN, DialogBox() doesnt return control until its closed. What can I use to pop a dialog box that will also allow me to control my OpenGL/D3D window ? This is what I am calling now:
DialogBox( hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, MainDlgProc );

INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
    HRESULT hr;

    switch( msg )
    {
        case WM_COMMAND:
            switch( LOWORD(wParam) )
            {
                case IDOK:
                case IDCANCEL:
                    EndDialog( hDlg, IDOK );
                    break;
            }
            break;

        default:
			{
	            swapBuffers(); // for window repaint
	            return FALSE; // Didn't handle message
			}
    }

    return TRUE; // Handled message
}
I tried adding a swap buffers call in MainDlgProc, and while the window repaints, it seems like the window (or at least it's thread) is frozen. Thanks for the help, Nitzan

Share this post


Link to post
Share on other sites
Advertisement
If I use createDialog, my dialog window does not draw. What do I have to do to fix this problem ?

this is how I create my dialog:


hDlg = CreateDialog( hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, MainDlgProc );


in wndProc() I call the following:


if(IsDialogMessage(hDlg, &msg)) {
MainDlgProc(hDlg, msg.message, msg.wParam, msg.lParam);
}


Thanks!

Nitzan Wilnai

Share this post


Link to post
Share on other sites
Quote:
Original post by nitzan

if(IsDialogMessage(hDlg, &msg)) {
MainDlgProc(hDlg, msg.message, msg.wParam, msg.lParam);
}



Thats wrong. IsDialogMessage calls your dialog proc for you. You want your message loop to look like this:

// Pump Messages //
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(IsDialogMessage(hDlg,&msg))
continue;

TranslateMessage(&msg);
DispatchMessage(&msg);
}




So you use the return value of IsDialogMessage() to decide if you need to call TranslateMessage and DispatchMessage

Share this post


Link to post
Share on other sites
I think it is

if (FocusWindow(windowhwnd))
{
DONT DO GETKEYSTATE OR WHATEVER YOU USE
}
else
{
do use it
}

But I'm not sure if it's focus window.

Uhh wtf that post just got removed which I answerd ?

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!