Found in 1 comment on Hacker News
bena · 2023-04-18 · Original thread
It looks like a pretty clean example from what I can recall.

WinMain builds the window and starts the message pump. The pump is implement starting at line 425. It's basically a while loop that reads the next message on the stack, translates it, then sends it to the object it belongs to.

It's the precursor to today's modern event-driven designs. Basically, this is now done for you by the runtime.

The bulk of the action happens in the created window's "wndproc", cbMainWindow (Line 455 - 2897).

There's a giant switch statement, with each handled message being a separate case. There's also a WM_COMMAND message, which is essentially a message holding another message inside.

This is probably the best book on Win32 API programming out there.

https://www.amazon.com/Programming-Windows%C2%AE-Fifth-Devel...

Fresh book recommendations delivered straight to your inbox every Thursday.