Thread: win32 GUI components

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    104

    win32 GUI components

    Hello,

    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.

    Thank you,
    abraham2119

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    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.

  3. #3
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    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.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by abraham2119 View Post
    I am trying to avoid using any resource files, and simply create the GUI dynamically.
    IMO this is a mistake.

    Use the right tool for the job.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Dec 2008
    Posts
    104
    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.

  6. #6
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 API GUI problems
    By Cha0sBG in forum Windows Programming
    Replies: 7
    Last Post: 06-05-2009, 04:35 PM
  2. Looking for free win32 gui (resource) editor
    By umen242 in forum Windows Programming
    Replies: 1
    Last Post: 05-22-2008, 03:49 AM
  3. Using Win32 Graphical Interface (GUI)
    By gadu in forum Windows Programming
    Replies: 1
    Last Post: 05-09-2008, 10:46 PM
  4. How can I pass arguments through a GUI (win32)?
    By bikr692002 in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2006, 05:17 PM
  5. Strings in Win32 GUI
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 09-26-2005, 06:55 AM