How does the window redraw?

I'm learning C++/WinAPI GUI elements. No MFC, no CLR, etc.

Using VS2010 I created a basic Win32 application, which auto-generates the code for a basic window. I spent some time learning about the message loop. For the sake of learning, I commented out the message loop.

As expected, my application just sits there. You can't close or manipulate it (short of Task Manager or whatnot).

However, when you hover over the minimize and maximize buttons, they animate (glow, as per Windows 7). How is that possible? WM_PAINT isn't being handled. No messages are being handled!
That is a feature of the UI (explorer.exe) and not the executable itself. Open task manager, kill "explorer.exe" and see if it still happens. You can launch explorer.exe from the Task Manager under File -> Run after you are done testing this.
Why kill explorer ? It will relaunch itself depending on some settings. On windows 7 click start -> press CTRL + SHIFT, right click -> exit explorer to gracefully terminating it.
Last edited on
I killed explorer and the window buttons still animate even without message processing in the window's associated process.

So, it can't be a "feature" of explorer.exe?
Of course is not a feature of explorer, even if you don't handle messages, some of them are processed default by windows, so you can minimize, maximize, resize without writing any specific code.

VS2010 calls DefWindowProc in the window procedure it generates automatically.
Thanks for more info. Could you clarify what actual process re-draws the minimize, maximize and close buttons when I mouse over them?

Does that DefWindowProc live inside my process? Why cannot I see it within VS2010? What if I wanted to change how it works?

My usual WindowProc, auto generated by a new projected, as messages commented out. So I'm assuming you're talking about other function I cannot currently see.

edit: I see DefWindowProc is the default switch in my WndProc function. Is that just a generic proc for literally every window (and control, so to speak) in Windows? If I comment out the default to it, my program exists upon opening.
Last edited on
Does that DefWindowProc live inside my process? Why cannot I see it within VS2010?


DefWindowProc is implemented in user32.dll. Yes it lives inside your process.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633572%28v=vs.85%29.aspx

What if I wanted to change how it works?


For exactly that purpose exists your own window procedure (WindowProc or whatever is called).
For more information see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633570(v=vs.85).aspx

For more information about each window message see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644927%28v=vs.85%29.aspx

Last edited on
Topic archived. No new replies allowed.