Launching a Direct3D window from a win32 dialog box

Started by
1 comment, last by MrCodeSushi 10 years, 9 months ago

Hi everyone,

I have a program which creates a dialog box initially, and I want to be able to press a button on the dialog box to create a window which DirectX will then render to. I think I could do this if my program wasn't dialog based (i.e. if I already had a win32 window) but I can't figure out how to do it when my main program is simply a dialog box. Here's my WinMain function:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINMENU), NULL, MainDlgProc);
}

As you can see, I don't create a message loop in the main program because it's only a dialog box. This is where my issue is raised. My DirectX window needs a message loop in order to work, and I'm not sure how I'd create one outside of WinMain. How could I create a separate window to render to by pressing a button on a dialog box? If anyone has any example code, that would be great :)

Thanks!

Advertisement

You may not realize it, but your dialog box is creating a message pump for you, which is subsequently processing all of the windows events that it gets passed. So if you want to intercept some of those messages, and allow them to be processed for your own window, then you have to check the docs about your dialog class and see if you can override the normal behavior.

I honestly don't know if it is possible, but even taking a close look at the headers for that class will probably tell you quite a bit about how it is implemented...

The MainDlgProc that you pass in is your defined function right? You should be able to catch the message that Jason Z is talking there.

This topic is closed to new replies.

Advertisement