Hi, anyone who can help....
In a small application (Excel 2010, 64 bit) I nave some Userform and on some I want to hide the caption bar with the Close, Minimize, etc. buttons. I am using this code:
Is there any code to restore the form in the initial state before unloading ?
In a small application (Excel 2010, 64 bit) I nave some Userform and on some I want to hide the caption bar with the Close, Minimize, etc. buttons. I am using this code:
and in the Activate event:Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Declare PtrSafe Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex _
As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex _
As Long, ByVal dwNewLong As LongPtr) As LongPtr
Private Declare PtrSafe Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, _
ByVal wParam As Integer, ByVal lParam As Long) As LongPtr
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal _
hwnd As LongPtr) As LongPtr
It works fine - hides what I need .... The problem is that if I don't close the app, with every unload /unload of the form, the content is moving up - I suppose some of the functions "cuts"a piece of the content a belt with the height of the border ...If Val(Application.Version) >= 9 Thenwhandle = FindWindow("ThunderDFrame", Me.Caption)
Else
whandle = FindWindow("ThunderXFrame", Me.Caption)
End If
If whandle = 0 Then Exit Sub
''
lStyle = GetWindowLong(whandle, GWL_STYLE)
Me.Caption = ""
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
lStyle = lStyle And Not WS_CAPTION
'SetWindowLong whandle, -20, frm
SetWindowLong whandle, GWL_STYLE, lStyle
DrawMenuBar whandle
Is there any code to restore the form in the initial state before unloading ?