Sign in to follow this  

redrawing scene while DialogBox is open

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

This topic is 4839 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this