|
こんばんわ。
SetWindowPos ってのはウィンドウの位置を設定する API で、
同時にサイズの変更もできるんやけど、SWP_NOSIZE を指定した場合は
そのときのウィンドウサイズは元のままってことやったと思うんやけどな。
サイズ変更を不可にするんとは違うんとちゃいまっか?
で、↓これでどうでっか?
Private Const GWL_STYLE = (-16)
Private Const WS_THICKFRAME = &H40000
Private Const WS_MAXIMIZEBOX = &H10000
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 FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Sub EnableWindowResize(ByVal flg As Boolean)
Dim hWnd As Long
Dim WndStyle As Long
Dim Ret As Long
hWnd = FindWindow("XLMAIN", Application.Caption)
WndStyle = GetWindowLong(hWnd, GWL_STYLE)
If flg Then
WndStyle = WndStyle Or WS_THICKFRAME Or WS_MAXIMIZEBOX
Else
WndStyle = WndStyle And (Not WS_THICKFRAME) _
And (Not WS_MAXIMIZEBOX)
End If
Ret = SetWindowLong(hWnd, GWL_STYLE, WndStyle)
Ret = DrawMenuBar(hWnd)
End Sub
Sub test()
MsgBox "リサイズ不可にします。"
EnableWindowResize False
End Sub
Sub test2()
MsgBox "リサイズ可能にします。"
EnableWindowResize True
End Sub
うまいこといかんかったらかんにんな。
ほな。
|
|