6 ms·
I've been wanting to dip my toes into old-school Win32 development for a while now, this codebase looks like a great example to pore over.
by cellularmitosis 3y ago
I've been wanting to dip my toes into old-school Win32 development for a while now, this codebase looks like a great example to pore over.
- waselighis 3y agoDave's Garage on YouTube has a couple good videos that I can recall. https://www.youtube.com/watch?v=JlZe2JwrJqM https://www.youtube.com/watch?v=JlZe2JwrJqM https://www.youtube.com/watch?v=CyJw2MumgTQ https://www.youtube.com/watch?v=CyJw2MumgTQ
- hansoolo 3y agoOh! I gonna dive into this pretty soon. Thank you!
- bena 3y agoIt 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-Developer-Reference/dp/157231995X https://www.amazon.com/Programming-Windows%C2%AE-Fifth-Devel...
- shortrounddev 3y agoYes, it's unfortunate that Programming Windows after 5ed became about XAML and C#. Those are good tools, but it's sad that they stopped updating the Win32/C++ resources as well.
- jansommer 3y agoUse ChatGPT! It's night and day for Win32 dev in my experience, and the code it produces is really good. One thing to note before going into Win32: You're going to have a pixelated, upscaled ui if you don't take care of high dpi support yourself, and that involves patching system controls. So prepare yourself for lots of dpi-work if that's a concern. (One thing I've been experimenting with is superclassing the system controls and "overwriting" the original by registering a superclass of eg. the edit control as simply "edit". This makes other system controls, like the combobox, use your dpi scaled/custom version).
- zerr 3y agoExactly my experience. In general, for the sane person, it is impossible to write more than a few lines of Win32 API code without copy/paste... ChatGPT came quite handy here.
- dataflow 3y agoI'm confused. Are you sure high DPI needs patching system controls to avoid pixelation? Doesn't dpiAwareness avoid the pixelation? I certainly haven't needed to patch anything for this in the past. If you have an example you could point to, that would be great, since I don't know if I'm missing something here. Also, question: do you know of a good way to test for high-DPI mode on a low-DPI screen?
- masfuerte 3y agoYou just need to add a manifest to your app indicating that you support high DPI. To test your app just change the DPI in the display settings.
- dataflow 3y agoI guess I was hoping for something little clunky than that, but thanks for the suggestion.
- jansommer 3y agoNope, you get the pleasure of implementing dpi support yourself. https://building.enlyze.com/posts/writing-win32-apps-like-its-2020-part-3/ https://building.enlyze.com/posts/writing-win32-apps-like-it...
- bananaboy 3y agoI love that this has been built with the old-school API! I've done a bit over the years and find it kind of pleasurable (maybe I enjoy torture!).
- poo-yie 3y agoAgreed! Sadly, lean GUI apps are mostly a thing of the past now.
- dncornholio 3y agoI had the same idea until I opened main.cpp and scrolled through 8911 lines of code
- zackangelo 3y agoThis also brought back memories for me of writing Win32 apps. If you're looking for a good book, checkout Programming Windows by Charles Petzold. It really demystified a lot of things for me and I bet it's still relevant if you want to write stuff like this.