Hi,
I have some code to remove X button from the UserForm. Problem is that each time I change UserForm's caption X button appears again. I could run that code each time I change caption, but I change it each half a second, so this approach is not desirable. Could anyone suggest me a way to make a permanent X button disappearance?
Also, do I need to use DrawMenuBar, it works well without calling this API?
Code:Code:Option Explicit 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 Const GWL_STYLE As Long = (-16) Private Const WS_SYSMENU As Long = &H80000 Private Sub UserForm_Activate() Dim lFormHandle As Long, lStyle As Long If Application.Version < "9.0" Then lFormHandle = FindWindow("ThunderXFrame", Me.Caption) Else lFormHandle = FindWindow("ThunderDFrame", Me.Caption) End If lStyle = GetWindowLong(lFormHandle, GWL_STYLE) lStyle = lStyle And Not WS_SYSMENU SetWindowLong lFormHandle, GWL_STYLE, (lStyle) DrawMenuBar lFormHandle End Sub


Reply With Quote