I was looking at Win32 C program today, from my MSDN CD. It does the same RegisterClass, CreateWindow and ShowWindow that most assembly samples do when they start up. But it didn't do the UpdateWindow call.

I did a little reading about WM_PAINT and it seems that it is issued at least once by the system, when there are no other messages to dispatch.

So I commented out the INVOKE in my "starter" program, and everything seems to be painting just fine. I know this is a minor issue, but now I'm wondering if that UpdateWindow might be doing something else, that I don't yet know about... :)
Posted on 2001-08-13 20:22:21 by S/390
If you create the first window with the WS_VISIBLE style, both the ShowWindow and UpdateWindow (before the message loop) are unnecessary. This has been the case since NT 3.1, the first version of Win32.

If I recall correctly, the ShowWindow in Win16 was used to set the window size (normal, minimized, maximized) to the state passed to the C program in the fourth WinMain argument. You can invoke GetStartupInfo to get this value.

A not-so-well-known fact is that the first call to CreateWindowEx already does this for you if the WS_VISIBLE style is specified. (The docs say it's the first call to ShowWindow, but my experiments with Win9x say it's actually the first call to CreateWindowEx.)
Posted on 2001-08-13 21:26:11 by tank