win32 GUI components
I am currently learning more in depth on how to create enriched GUI's in C using the win32 API. I am trying to avoid using any resource files, and simply create the GUI dynamically.
From what I have seen, in order to add components to the GUI dynamically, I have two options; sending a specific message to the message queue (such as a TB_ADDBUTTONS message) or using the CreateWindow() function and using a predefined control class (such as BUTTON) and setting the HWND parameter to the parents' window.
This brings me to these questions,
1. When using CreateWindow(), the win32 API only provides 9 predefined control classes. Does this mean that these 9 components are the only components available to add to your window when programming a GUI by using the win32 API?
2. When using the CreateWindow() alternative, and after setting the HWND parameter to the parents', are the 'x' and 'y' attributes limited to be within the parents' coordinates, or not? If so, what will happen when they are not within the parents' coordinates?
Extra: I have searched for a full list of all types of messages that could be sent to the message queue, but have not found it. If someone could find it, please link me to it.
No, there are extended styles and controls. Each one of those classes has multiple styles associated with them that you can use. I really don't know for the 2nd question because I've never needed to do it (IE why would youw ant to do this?). Most likely the control will just be undrawable.
Keep in mind you are not limited to the control classes that windows defines, you can also use owner drawn controls where you can take control of the draw code explicitly.
For the messages your best bet is MSDN (WM_COMMAND etc...), searching online in google for what you want to do, or buy an API bible with all the messages (probably very cheap now).
And gl creating "enriched" gui's in C with pure win32 api hehe...won't be easy.
1. No. The Win32 acutally provides much more than just 9 classes, see common controls. Look at any Win32 introduction -- when they create their base window, if they make use of WNDCLASSEX, then they're adding to that list. You can create your own controls through the same method used to create windows, basically...
2. Yes. Depends. Most likely is that the window will just get clipped, and won't be visible. The parent window might add scroll bars to allow you to see it though.
@valaris: Everything in Windows in some way uses the Win32 API. If you program GUI stuff long enough, you will have to deal with Win32. MFC, C#, etc. will not get you all the way.
IMO this is a mistake.
Originally Posted by abraham2119
Use the right tool for the job.
Thanks for all the answers, but honestly, I knew that I had the ability to create custom control classes. My real question was whether those 9 control classes are the only control classes that the win32 API provides you with.
Those 9 are the ones provided by User32, they're all you can use unless comctl32 is loaded which then provides you with bucketloads more as well as stylized versions of the original nine (in version 6). This is why in password editboxes you sometimes see circles and sometimes asteriks, it depends on whether the app is using the comctl version of the editbox control or the user32 version.