Sign in to follow this  

Launching a Direct3D window from a win32 dialog box

Recommended Posts

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



Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

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