CSDN博客

img lang_csdn

控制MDI窗口的,最大化.最小化按钮!

发表于2004/10/31 15:40:00  954人阅读

Private Declare Function GetSystemMenu Lib "USER32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "USER32" (ByVal hMenu 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" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "USER32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const GWL_STYLE = (-16)
Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&
Private Sub MDIForm_Load()
    Dim lWnd As Long
    DisableX
    lWnd = GetWindowLong(Me.hwnd, GWL_STYLE)
    lWnd = lWnd And Not (WS_MINIMIZEBOX)
    lWnd = lWnd And Not (WS_MAXIMIZEBOX)
    lWnd = SetWindowLong(Me.hwnd, GWL_STYLE, lWnd)
End Sub


Private Sub DisableX()
        '/* 不显示控制菜单
         Dim hMenu, nCount, LO     As Long
         hMenu = GetSystemMenu(Me.hwnd, 0)
         nCount = GetMenuItemCount(hMenu)
         LO = RemoveMenu(hMenu, nCount - 3, MF_REMOVE Or MF_BYPOSITION)
         LO = RemoveMenu(hMenu, nCount - 4, MF_REMOVE Or MF_BYPOSITION)
End Sub

 

阅读全文
0 0

相关文章推荐

img
取 消
img