Jump to content
  • Advertisement
Sign in to follow this  
george7378

Launching a Direct3D window from a win32 dialog box

This topic is 1816 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 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!

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

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.

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!