VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Center a form, relative to the available workspace

Dave Hng  (4 Submissions)   Custom Controls/Forms/Menus   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Centers a form, relative to the available workspace. This means that if your users have high, or wide taskbars, or other apps which restrict the workspace, your forms will still center properly.

Inputs
General usage: Stick this in the form's show event: Center Me

Returns
It's a sub, so no returns.

Side Effects
If the workspace is smaller than the form, it still centers, so part of the form will be off the visible area (of course this is a problem with all form centering code).

API Declarations
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Global Const SPI_GETWORKAREA As Long = 48

Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Rate Center a form, relative to the available workspace (4(4 Vote))
Center a form, relative to the available workspace.bas

Center a form, relative to the available workspace Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters