Wndclassex And Wndclass

This is a discussion on Wndclassex And Wndclass within the Windows Programming forums, part of the Platform Specific Boards category; Yesterday I was reading Programming Windows 5th edition by Charles Petzold and he uses the line WNDCLASS wndclass; // to ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    95

    Wndclassex And Wndclass

    Yesterday I was reading Programming Windows 5th edition by Charles Petzold and he uses the line
    WNDCLASS wndclass; // to declare his windows class

    Today I was reading through theForger's Win32 Api (A simple window) and he uses the line:
    WNDCLASSEX wndclass;

    I noticed there was a difference in the first attribute set for WNDCLASSEX ie:
    wc.cbSize = sizeof(WNDCLASSEX);

    where as Petzold didn't feel the need to specify this attribute which I assume is used in case of future additions to WNDCLASSEX

    My question is more general though, what are the differences between these two classes and when should I use either one?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    The differences stem from the difference between windows 3.0 and windows 3.1.
    When windows 3.0 was released it only supported a few window styles. Over the years microsoft has decided to add to these and with the release of windows 3.1 they introduced the WNDCLASSEX struct and the RegisterClassEx() api function. The main difference is that this structure includes an extended style field. This gives you much more choice of the look and behaviour of your windows. At first with windows 3.1 there were only about 4 extended styles. Now there are lots more. Each new edition of windows seems to add something to the extended styles.

    Most windows programmers say if you dont need extended styles then use WNDCLASS and RegisterClass() and if you do then use WNDCLASSEX and RegisterClassEx(). I say use WNDCLASSEX all the time and if you dont need extended styles set that field to 0. Best way of futureproofing your code.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    btq
    btq is offline
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    from MSDN:
    The WNDCLASSEX structure is similar to the WNDCLASS structure. There are two differences. WNDCLASSEX includes the cbSize member, which specifies the size of the structure, and the hIconSm member, which contains a handle to a small icon associated with the window class.
    hope that helps

    /btq
    ...viewlexx - julie lexx

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    95

    Talking

    Thanks for the help that cleared things up.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. converting to WNDCLASSEX
    By Darth in forum Windows Programming
    Replies: 2
    Last Post: 12-07-2007, 05:31 PM
  2. What's the difference between WNDCLASS and WNDCLASSEX?
    By Antigloss in forum Windows Programming
    Replies: 3
    Last Post: 03-16-2006, 02:59 PM
  3. DialogBoxIndirect(...) vs. WNDCLASS, CreateWindow etc.
    By SMurf in forum Windows Programming
    Replies: 1
    Last Post: 11-30-2003, 06:07 AM
  4. wndclass data questions
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 10:01 PM
  5. WNDCLASSEX vs. WNDCLASS (Newbe) ???
    By niklaskr in forum Windows Programming
    Replies: 3
    Last Post: 06-19-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21