Click to See Complete Forum and Search --> : Using the dialog editor to create child windows


Gyannea
June 1st, 2004, 04:45 PM
This question isn't the most sophisitcated, but what I would like to do is place a bunch of child windows (buttons, static boxes) within a window (not a dialog box) but using the dialog editor. All I want is the position and size information for these child windows and then I can use that info to locate the boxes within my window.

It's so easy to design the layout using the dialog editor I would like to take advantage of that.

I don't want to use an owner draw dialog box since I use virtual bitmap windows for WM_PAINT messages. I draw everything into the virtual window and then invalidate. The overhead is a lot less than normal dialog box redraws.

Anyways, can I get coordinate information from the child windows created by the dialog box editor without ever using or creating the dialog box?

Brian

NoHero
June 2nd, 2004, 11:37 AM
There might be a very strange way ... With the function "CreateDialogIndirect" you can create a dialog that is handlet as a child window of another window ...

Just search for CreateDialogIndirect ... You will find what I adore ... ;)

ng nohero

RussG1
June 2nd, 2004, 01:07 PM
You could create a dialog using the dialog editor and position all the controls where you want them and compile. The .rc file contains all of the layout information (sizes and positions, etc), so you can open it up in a text editor, and refer to that info to manually position your controls within your window when you create them, etc.

Gyannea
June 2nd, 2004, 07:13 PM
Is there no structure one can address that will give these values? I would like not to hard code them, in case the stuff needs to be shuffled around. Hard to please everyone, you know!

I am not sure I understand the CreateDialogIndirect...will have to investigate that further.

By the way, anyone know what the name of the font is that windows uses when you create a button class child window (outside of a dialog box) and place text in it? It's not the default value used in the dialog box! I tried getting the stock object fonts, but the sizes given by GetTextExtentPoint32() were not correct.

Brian

RussG1
June 2nd, 2004, 09:58 PM
I do not know of any tools for control layout for a non-dialog/non-form based window. One possibility might be to create a settings dialog with your control layout (maybe even make the controls dragable on the dialog at run time, for repositioning at run time, etc), that you use for positioning your controls (i.e. create dialog initially hidden, read layout info and create your controls in your main window using that info (can destroy dialog when no longer needed)... possibly use a settings menu item to show the dialog, and allow the user to move the controls around as they like and on OK, reposition controls in main window using new layout, etc). If nothing else, it might be a useful way to try out different layouts until you find the one you like the best, and then hard code the layout in the program.

As for the font. I believe buttons on a dialog use the same font that is set for the dialog (using dialog editor). I think buttons that are not on a dialog use SYSTEM_FONT (i.e. GetStockObject(SYSTEM_FONT) ), but I am not completely sure about that.

Gyannea
June 3rd, 2004, 05:05 AM
Russ,

You are correct; it is the SYSTEM_FONT. I had forgotten to take into consideration the frame of the button and that was causing the squeeze.

It looks like trying to use the editor is going to be a challenge. However, hard coding the numbers in the 'rc' file is easier than trying to guess them or manipulate them by trial and error!

Brian