Jump to content
  • Advertisement
Sign in to follow this  
Talib

Dynamic Dialog Box w/o resources

This topic is 4829 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 I am writing a d3d9 wrapper class that I want to use in all my projects, just for the set-up of D3D. What I would like to have before the D3D is set up, is a Dialog Box that pops up prompting me to choose things like: Fullscreen/Windows, resolution etc. However, I do not want a resource.h file with the dialog box template having to travel around wherever my D3D class goes. So here is my question: Is there a way to create a modal dialog box without resources?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Talib
So here is my question: Is there a way to create a modal dialog box without resources?


Yes. You'll need to create the dialog box manually via the DLGTEMPLATE and DLGITEMTEMPLATE data structures (documented in MSDN). The easiest way is to actually create the dialog box in a resource file, load it into memory via FindResource()/LoadResource(), then dump it as raw data that can be included in a source file (i.e. unsigned char resource_data[] = {.....}; ) - which can be done with GlobalLock(). The dialog box can then be created via DialogBoxIndirect() which takes a DLGTEMPLATE as one of it's arguments.

Share this post


Link to post
Share on other sites
Thanks sounds easy. Just a couple of things.

1. According to the VC help LoadResource() returns HGLOBAL but it should not be used with GlobalLock() and rather LockResource()

2. How would you dump the raw data?

3. After I implement the unsigned char data to cast it to a DLGTEMPLATE for use with DialogBoxIndirect()?

Share this post


Link to post
Share on other sites
Quote:
Original post by Talib
Thanks sounds easy. Just a couple of things.

1. According to the VC help LoadResource() returns HGLOBAL but it should not be used with GlobalLock() and rather LockResource()

2. How would you dump the raw data?

3. After I implement the unsigned char data to cast it to a DLGTEMPLATE for use with DialogBoxIndirect()?



1. Yes. Definitely use LockResource rather than GlobalLock.

2. After you lock the resource handle use the SizeofResource() function to get it's size and dump it either using printf() or similar method to export the data to a file.

3. You can either do a cast or dump the data in the actual data structures it uses:
struct DialogResource {
DLGTEMPLATEEX dlgtpl;
DLGITEMTEMPLATEEX dlgitems[];
};

DialogResource d3dchooser = {
{style, exstyle, itemcount, x, y, cx, cy},
{
// dialog items
{style, exstyle, x, y, cx, cy, id},
{style, exstyle, x, y, cx, cy, id},
{style, exstyle, x, y, cx, cy, id}
}
};


You still need to include the additional data such as the menu and control type ordinals but that's fairly straight forward. The required data and the layout of the resources are well documented in MSDN it just takes a bit of digging to put it all together.

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!