同意阿甘,如果不是Mdi窗体的话,杀鸡何必用牛刀。

解决方案 »

  1.   

    哦,对不起,题目没有看全!!!!!!!!!!!!!!!
    在另外一个帖子中抄了阿甘的代码,试试看/:Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Const MF_BYCOMMAND = &H0&
    Const MF_REMOVE = &H1000&
    Const MF_BYPOSITION = &H400&Private Sub Form_Load()
        Dim hSysMenu As Long, nCnt As Long
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)
        hSysMenu = GetSystemMenu(Me.hwnd, False)
        If hSysMenu Then
            ' Get System menu's menu count
            nCnt = GetMenuItemCount(hSysMenu)
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
                RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
                RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
                'DrawMenuBar Me.hwnd
                ' Force caption bar's refresh. Disabling X button
                'Me.Caption = "Try to close me!"
            End If
        End If
    End Sub
      

  2.   

    gump2000(阿甘) ,我是用在MDI窗体中呢!要不我问这个题目干什么呀!
      

  3.   

    这段代码是最大化按钮没有作用,但没有灰掉。Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Const MF_BYCOMMAND = &H0&
    Const MF_REMOVE = &H1000&
    Const MF_BYPOSITION = &H400&Private Sub mdiForm_Load()
        Dim hSysMenu As Long, nCnt As Long
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)
        hSysMenu = GetSystemMenu(Me.hwnd, False)
        If hSysMenu Then
            ' Get System menu's menu count
            nCnt = GetMenuItemCount(hSysMenu)
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
    '            RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
    '            RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
                RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
    '            DrawMenuBar Me.hwnd
                ' Force caption bar's refresh. Disabling X button
                'Me.Caption = "Try to close me!"
            End If
        End If
    End Sub
      

  4.   

    combread(大点) ,这个代码我试过了,它只是灰掉了关闭按钮而已呢!
      

  5.   

    MDI的话,就用上面代码嘛
    不灰掉但是已经不起作用了:)
      

  6.   

    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Const MF_BYCOMMAND = &H0&
    Const MF_REMOVE = &H1000&
    Const MF_BYPOSITION = &H400&
    Private Sub MDIForm_Load()Dim hSysMenu As Long, nCnt As Long
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)
        hSysMenu = GetSystemMenu(Me.hwnd, False)
        If hSysMenu Then
            ' Get System menu's menu count
            nCnt = GetMenuItemCount(hSysMenu)
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
    '            RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
    '            RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
                RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
    '            DrawMenuBar Me.hwnd
                ' Force caption bar's refresh. Disabling X button
                'Me.Caption = "Try to close me!"
            End If
        End If    LoadNewDoc
    End Sub
    没有啊!!!
    绝对可以执行啊
      

  7.   

    gump2000(阿甘),唉,这段没有问题?不过还是要去掉最后一句“LoadNewDoc”呢,才能起到作用!谢谢你,等下给分!
      

  8.   

    我试了,真的没有问题
    除非您在您的loadnewdoc代码中写了什么
      

  9.   

    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Const MF_BYCOMMAND = &H0&
    Const MF_REMOVE = &H1000&
    Const MF_BYPOSITION = &H400&
    ''''
    'API申明,没有什么好说的吧
    ''''
    Private Sub MDIForm_Load()Dim hSysMenu As Long, nCnt As Long
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)    hSysMenu = GetSystemMenu(Me.hwnd, False)'获取本form的menu的句柄
        If hSysMenu Then
            ' Get System menu's menu count
            nCnt = GetMenuItemCount(hSysMenu)'获取menu的item count
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
                RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE'把倒数第三个menu给delete掉
            End If
        End If    LoadNewDoc
    End Sub
      

  10.   

    分儿
    MF_BYPOSITION '按照位置来计算