VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Toggle a Form's Caption Bar at Runtime

Stephen Kent  (10 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

This code allows a user to Toggle the caption bar (toolbox and all) on a form at runtime. Normally you cannot visually change some of the form's settings at runtime this solves one of those instances.
Code can be fairly easily changed so as to accept a parameter for if you want the caption or not. This is just a simple example.

Assumes
This simply changes the window style of the form and then does a couple of extremely quick re-sizes so that the caption area is forced to redraw. This will only work as is if the code is placed in the form you want to affect. Sub must be called for changes to take effect.

API Declarations
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const SWP_NOMOVE = &H2
Private Const WS_CAPTION = &HC00000
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Rate Toggle a Form's Caption Bar at Runtime (2(2 Vote))
Toggle a Form's Caption Bar at Runtime.bas

Toggle a Form's Caption Bar at Runtime Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters