Thread: A few Windows prog questions

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    A few Windows prog questions

    I am learning Windows programming from Charles Petzold's Programming Windows 5th Edition. Well, I decided to take a look at www.winprog.org to take a look at the tutorial. Well, it seems to have contrasting code with Petzold. For instance
    Code:
        //Step 1: Registering the Window Class
        wc.cbSize        = sizeof(WNDCLASSEX);
        wc.style         = 0;
        wc.lpfnWndProc   = WndProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
        wc.lpszMenuName  = NULL;
        wc.lpszClassName = g_szClassName;
        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    Well, I never learned that last field of the Window class (wc.hIconSm). What is that?
    Code:
    // Step 4: the Window Procedure
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch(msg)
        {
            case WM_CLOSE:
                DestroyWindow(hwnd);
            break;
            case WM_DESTROY:
                PostQuitMessage(0);
            break;
            default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
    }
    And their WndProc, I didn't learn with the WM_CLOSE. What is that when you have WM_DESTROY? Does it just go to WM_DESTROY?

    Thanks.

    --Garfield the Great
    1978 Silver Anniversary Corvette

  2. #2
    >>Well, I never learned that last field of the Window class (wc.hIconSm). What is that?

    this is the small icon that windows uses(like in your explorer)
    You can use a different icon for it because otherwise windows just removes some lines from your icon and it can get messed up


    >>And their WndProc, I didn't learn with the WM_CLOSE. What is that when you have WM_DESTROY? Does it just go to WM_DESTROY?

    A WM_CLOSE is sent when u press the X in the upper right corner.
    A WM_DESTROY is sent when you use DestroyWindow(hwnd);

    don't shoot me if this is wrong, Im'only learnig myself

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Thanks for the reply!

    --Garfied the Great
    1978 Silver Anniversary Corvette

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I was just looking at the tutorial more, and I found that the window class data type isn't

    WNDCLASS

    it is

    WNDCLASSX

    Anybody know what that means?

    --Garfield the Great
    1978 Silver Anniversary Corvette

  5. #5
    WNDCLASSEX just has some extra members (hIconSm and cbSize)
    cbSize is the size of the structure

  6. #6
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Why would you want to use WNDCLASSEX? What are the benefits?
    1978 Silver Anniversary Corvette

  7. #7
    don't know. I almost never use it. I gues you would use it when you want a small icon. maybe there are some other benefits but I can't find any

  8. #8
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Okay, thanks for the explanation!
    1978 Silver Anniversary Corvette

  9. #9
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    Code:
    case WM_CLOSE: // sent when [X] is clicked, or ALT-F4
                DestroyWindow(hwnd);	// Destroy the Window message
            break; // wait for user to respond before destroying window
    case WM_DESTROY:// if WM_CLOSE is done, then close window
                PostQuitMessage(0);

  10. #10
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Thanks for the explanation.
    1978 Silver Anniversary Corvette

  11. #11
    Registered User DutchStud's Avatar
    Join Date
    Oct 2001
    Posts
    43

    Benefits of WNDCLASSEX

    The only benefit of WNDCLASSEX over WNDCLASS is the small icon deal. that's it, unless you can find some crazy use for defining the size of the structure.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Network Programming in C for Windows
    By m.mixon in forum C Programming
    Replies: 7
    Last Post: 06-19-2006, 08:27 PM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. Windows Rant followed by installation question
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 06-21-2003, 04:42 PM
  5. How come this only works in Windows nt/2000?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2002, 06:54 PM