Thread: Why UpdateWindow() after ShowWindow()?

  1. #1
    the Corvetter
    Join Date
    Sep 2001

    Why UpdateWindow() after ShowWindow()?

    In WinMain after you CreateWindow, there is:
    ShowWindow(hwnd, nCmdShow);
    I wasn't sure why UpdateWindow was there, so I temporarily took it out and the program did the same exact thing.

    Can somebody explain this? I realize what UpdateWindow does (If there is an invalid region on the client area and UpdateWindow is called, then a WM_PAINT message bypasses the message queue and the WndProc proccesses the WM_PAINT message).


    1978 Silver Anniversary Corvette

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    ShowWindow() only sets the "show-state". It doesn't actually force a painting so we do that by calling UpdateWindow() which forces the window to be painted.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    exactly, so if you had to draw buttons or something on your window and you didn't have UpdateWindow() in there, you would have to force a repaint by dragging the window/minimizing it, etc. you could probably replace that with SendMessage(hwnd, WM_PAINT, 0, 0);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ShowWindow Problem
    By dhrodrigues in forum Windows Programming
    Replies: 4
    Last Post: 07-07-2004, 11:16 AM
  2. Maximizing window with MFC
    By Gravedigga in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2003, 03:17 PM
  3. Need some more assistance
    By Thantos in forum Windows Programming
    Replies: 6
    Last Post: 08-14-2003, 12:13 PM
  4. ShowWindow causing Access Violations - please help
    By Arrow Mk 84 in forum Windows Programming
    Replies: 8
    Last Post: 08-06-2002, 06:09 PM