Jump to content
  • Advertisement
Sign in to follow this  

[C++ Win32] Tying Windows to a resource?

This topic is 3964 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 can't believe how difficult it is to get into Win32 GUI programming, windows, dialogs and all that. I've read numerous tutorials and from that I have gathered: 1. Windows can not be tied to a Visual Studio resource, and if you want to add something in them you have to do it programmatically. 2. Dialogs, on the other hand, can be tied to a resource. However, you need a main window before you can push any dialogs around, and you can't have multiple dialogs up at the same time (unless they are non-modal?). Really, what I'm trying to do is to seperate my database editor into different areas, one with rows, and another showing a list of tables - etc. I really like the idea of using resources rather than programmatically creating everything. My question: Is there a possibility to do what I want or should I just forget it and keep hammering at it?

Share this post


Link to post
Share on other sites
Advertisement
If you want to tie a window to a dialog resource, you must
1) setup the dialog without borders, and with the WS_CHILD style.
2) create a dialog which is a child to your window.
3) profit.

But yes, you are true, you cannot tie a window to a resource, because there is no resource that have the window type - the nearest thing you'll get is a dialog resource, and dialogs are a bit more specialized than windows.

You can have multiple dialogs at the same time - if they are non-modal, or if they are modal but running in different threads.

You have to know too that a dialog can be your application window.

Share this post


Link to post
Share on other sites
Merci beaucoup, Emmanuel.

Quote:

If you want to tie a window to a dialog resource, you must
1) setup the dialog without borders, and with the WS_CHILD style.
2) create a dialog which is a child to your window.
3) profit.


When I do this, both the Window and the Dialog stops responding from mouse clicks, so I have to destroy it trough the task manager. The dialog is a non-modal child without borders.

Quote:

You have to know too that a dialog can be your application window.


I tried creating a dialog before my main window, but it doesn't show itself.

In any case - you have confirmed that it's possible and that I just need to learn how to do it. I'll try to find a definition of Window and Dialog and see if the latter is enough for my needs. I hope so.

Thanks again, you've been of much help.

Share this post


Link to post
Share on other sites
Quote:
Original post by SymLinked
2. Dialogs, on the other hand, can be tied to a resource. However, you need a main window before you can push any dialogs around, and you can't have multiple dialogs up at the same time (unless they are non-modal?).


Just call DialogBox() at start of WinMain. WinMain execution will stop, and you can continue program in another procedure (or thread), calling it in receiving WM_INIDIALOG message. If you need window to access the message loop, just create a window as a child of dialog box. You can also read about MDI child windows (and dialogs)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!