Всем добрый день.
У меня есть MDI форма. Мне нужно чтоб ее можно было только закрыть или минимизировать. И соответственно нужно убрать кнопочку "максимизировать" или "востановить прежний размер".
Как это сделать?
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const SC_MAXIMIZE As Long = &HF030&
Private Const MF_BYCOMMAND As Long = &H0&
Private Sub MDIForm_Load()
Dim h As Long
h = GetSystemMenu(Me.hwnd, 0)
If h Then RemoveMenu h, SC_MAXIMIZE, MF_BYCOMMAND
End Sub
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags 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 GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = -16
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const SC_MAXIMIZE As Long = &HF030&
Private Const SC_RESTORE = &HF120&
Private Const MF_BYCOMMAND As Long = &H0&
Private Sub MDIForm_Load()
Dim h As Long
h = GetSystemMenu(Me.hwnd, 0)
If h Then
RemoveMenu h, SC_MAXIMIZE, MF_BYCOMMAND
RemoveMenu h, SC_RESTORE, MF_BYCOMMAND
End If
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) And Not WS_MAXIMIZEBOX
End Sub
MDIForm1.Caption = "forma"
If Me.WindowState = 0 Then Me.WindowState = 2
Сейчас этот форум просматривают: SemrushBot, Yandex-бот и гости: 8