Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel hide caption bar...
Happy 2007 Everyone!
I am in need of some code to completely remove the CAPTION BAR from a VB User Form (The bar at the top of the user form that has the form caption, minimize, maximize, and close buttons). I use to have a working example of the code but I managed to lose it. Any help is much appreciated!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel hide caption bar...
Put all this in the Userform code module at the top: (make sure you have a
way to close the userform - such as the code in the commandbutton). Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) _ As Long Private Declare Function GetWindowLong _ Lib "user32" _ Alias "GetWindowLongA" _ ( _ ByVal hWnd As Long, _ ByVal nIndex As Long _ ) _ 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 DrawMenuBar _ Lib "user32" _ ( _ ByVal hWnd As Long _ ) _ As Long Private Function fncHasUserformCaption _ ( _ bState As Boolean _ ) 'change the style of the Userform window to have a 'caption or not to 'declarations of variables Dim Userform_hWnd As Long Dim Userform_Style As Long 'required API consatants Const GWL_STYLE = (-16) Const WS_CAPTION = &HC00000 'get a handle to the userform window Userform_hWnd = FindWindow _ ( _ lpClassName:=IIf(Val(Application.Version) 8, _ "ThunderDFrame", _ "ThunderXFrame"), _ lpWindowName:=Me.Caption _ ) 'get the current style of the window Userform_Style = GetWindowLong _ ( _ hWnd:=Userform_hWnd, _ nIndex:=GWL_STYLE _ ) 'deside whether to redraw the form with a caption or without 'based on the bState parameter If bState = True Then Userform_Style = Userform_Style Or WS_CAPTION Else Userform_Style = Userform_Style And Not WS_CAPTION End If 'set the new style to the window Call SetWindowLong _ ( _ hWnd:=Userform_hWnd, _ nIndex:=GWL_STYLE, _ dwNewLong:=Userform_Style _ ) 'redraw the window using the new style Call DrawMenuBar _ ( _ hWnd:=Userform_hWnd _ ) End Function Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() fncHasUserformCaption False End Sub -- Regards, Tom Ogilvy wrote in message ups.com... Happy 2007 Everyone! I am in need of some code to completely remove the CAPTION BAR from a VB User Form (The bar at the top of the user form that has the form caption, minimize, maximize, and close buttons). I use to have a working example of the code but I managed to lose it. Any help is much appreciated!!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel hide caption bar...
Code worked great Tom! When I become a millionaire Ill track you down
and name a wing of a hospital after you...LoL Happy New Years Buddy! -Todd Tom Ogilvy wrote: Put all this in the Userform code module at the top: (make sure you have a way to close the userform - such as the code in the commandbutton). Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) _ As Long Private Declare Function GetWindowLong _ Lib "user32" _ Alias "GetWindowLongA" _ ( _ ByVal hWnd As Long, _ ByVal nIndex As Long _ ) _ 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 DrawMenuBar _ Lib "user32" _ ( _ ByVal hWnd As Long _ ) _ As Long Private Function fncHasUserformCaption _ ( _ bState As Boolean _ ) 'change the style of the Userform window to have a 'caption or not to 'declarations of variables Dim Userform_hWnd As Long Dim Userform_Style As Long 'required API consatants Const GWL_STYLE = (-16) Const WS_CAPTION = &HC00000 'get a handle to the userform window Userform_hWnd = FindWindow _ ( _ lpClassName:=IIf(Val(Application.Version) 8, _ "ThunderDFrame", _ "ThunderXFrame"), _ lpWindowName:=Me.Caption _ ) 'get the current style of the window Userform_Style = GetWindowLong _ ( _ hWnd:=Userform_hWnd, _ nIndex:=GWL_STYLE _ ) 'deside whether to redraw the form with a caption or without 'based on the bState parameter If bState = True Then Userform_Style = Userform_Style Or WS_CAPTION Else Userform_Style = Userform_Style And Not WS_CAPTION End If 'set the new style to the window Call SetWindowLong _ ( _ hWnd:=Userform_hWnd, _ nIndex:=GWL_STYLE, _ dwNewLong:=Userform_Style _ ) 'redraw the window using the new style Call DrawMenuBar _ ( _ hWnd:=Userform_hWnd _ ) End Function Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() fncHasUserformCaption False End Sub -- Regards, Tom Ogilvy wrote in message ups.com... Happy 2007 Everyone! I am in need of some code to completely remove the CAPTION BAR from a VB User Form (The bar at the top of the user form that has the form caption, minimize, maximize, and close buttons). I use to have a working example of the code but I managed to lose it. Any help is much appreciated!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I add a caption to a picture in Excel | Excel Discussion (Misc queries) | |||
Caption attribute at Cell in Excel XML | Excel Discussion (Misc queries) | |||
Caption at Cell level of Excel XML | Excel Discussion (Misc queries) | |||
Hide Window Caption Bar | Excel Programming | |||
How to reference win.caption, when caption changes | Excel Programming |