In the past few days, I embarked upon a project to port Antoni Sawicki’s aclock, a small text-based clock program (aclock stands for analog clock), to 16-bit Windows. While aclock itself has been ported to over 150 platforms, it is a console program, so a chunk of new Windows-specific code had to be written.
For guidance I went to Charles Petzold’s classic, Programming Windows, in the second edition which covers Windows 3.0. To keep things simple, the Windows version of aclock chooses one of the stock fixed-pitch fonts offered by Windows, calculates how many characters fit into the application’s window horizontally and vertically, and treats the window as a text console in order to draw the clock. The clock is updated every second and resized if the window size changes.