by Tom Pydeski (16 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(13 Votes)
This code will read the active titlebar height and font parameters. The Caption of the window is then centered with the date and time. I looked long and hard to try to do this. Most PC's don't use a proportional font for the titlebar and thus the amount of characters displayed depend on the size of the character (i.e. "WWWWWWWWWW" is wider than "llllllllll" in most non-proportional fonts). I found some info on the web and modified it to allow the caption to be centered in the area between the titlebar bitmap and the 3 controlboxes. The Titlebar size and the titlebar font & size can be different from machine to machine. These settings affect how much data can be displayed in the caption of the window, as does the screen resolution. I had originally tried constants based on the form width, but these were not 100%. Try changing the form size and the active title bar settings to see it in operation.
Inputs
Caption Text
Code Returns
nothing
Side Effects
none (hopefully!)
API Declarationssee code
Upload