|
Win32APIを使わないと出来ません。
以下のコードを全て、フォームモジュールの先頭から入れて下さい。
Private Declare Function FindWindow Lib "user32.dll" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" 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 = -16
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_THICKFRAME = &H40000
Private Const WS_SYSMENU = &H80000
Private Sub UserForm_Initialize()
Dim hwnd As Long, lngNew As Long, rc As Long
hwnd = FindWindow("ThunderDFrame", Me.Caption)
lngNew = GetWindowLong(hwnd, GWL_STYLE)
rc = SetWindowLong(hwnd, GWL_STYLE, lngNew And _
(Not WS_SYSMENU))
rc = DrawMenuBar(hwnd)
End Sub
Private Sub UserForm_MouseUp(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim hwnd As Long, lngNew As Long, rc As Long
hwnd = FindWindow("ThunderDFrame", Me.Caption)
lngNew = GetWindowLong(hwnd, GWL_STYLE)
rc = SetWindowLong(hwnd, GWL_STYLE, lngNew Or WS_SYSMENU _
Or WS_THICKFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
End Sub
ユーザーフォームを Show したあと、タイトルバーを確認したら
それをクリックして下さい。ボタンが復活すると思います。
でも念の為、テストする際はコマンドボタンを配置して UserForm を
Unload できるイベントも追加しておいた方がいいです。
|
|