VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Center Text in the Windows Titlebar

Tom Pydeski  (16 Submissions)   Miscellaneous   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

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

Returns
nothing

Side Effects
none (hopefully!)

API Declarations
see code

Rate Center Text in the Windows Titlebar (13(13 Vote))
Center Text in the Windows Titlebar.bas

Center Text in the Windows Titlebar Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters