tags:

views:

144

answers:

5

I'm wondering what the correct way of creating Gui's in with Win32 API. Right now I just call the CreateWindowEx in my WM_CREATE event, but I don't think this is the right way to do it. Just as an example, what would be the correct way of adding a 100x20 EditField and getting text from it? Would you create it on WM_Create then use GetText()?

Thanks

+1  A: 

Some pretty good examples here:

http://www.rohitab.com/discuss/index.php?showtopic=11454

Robert Harvey
+1  A: 

Also, I highly recommend getting a copy of Petzold if you're going to subject yourself to the Windows API:

http://www.amazon.com/Programming-Windows-Microsoft-Charles-Petzold/dp/157231995X

Dave Markle
+1  A: 

Here is another site with pretty good examples - http://www.winprog.org/tutorial/start.html It also looks like they have an Italian translation :)

This has to be duplicate of many posts if we are all going to post sample web sites for Win32

Romain Hippeau
A: 

If you are creating a simple gui with the windows api, then use a resource editor to create your dialog box resource, and then replace your apps window class registration and window creation code with a simple call to DialogBoxParam. DialogBoxParam will read the dialog resource and create the dialog automatically scaling everything to the users font settings, handle the message loop and do other things like automatic support of tabbing between controls.

Chris Becke
one thing - you have to update valid theme fonts yourself for the controls, otherwise you will get default fonts from .res dialog box description
Bartosz Wójcik
A: 

You don't need to do it in the WM_CREATE event, but you can. I usually create any child windows in the same scope where the main window was created. For example:

HWND mainWindow = CreateWindowEx(...);
HWND editField = CreateWindowEx(...); // use mainWindow for the hWndParent param
                                      // the hMenu parameter sets child window id
StackedCrooked