禁止x按钮及关闭菜单

页面导航:首页 > 软件编程 > vb.net > 禁止x按钮及关闭菜单

禁止x按钮及关闭菜单

来源: 作者: 时间:2016-02-05 12:32 【

Option ExplicitPrivate Declare Function GetSystemMenu Lib "user32"_(ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function GetM

 

 

Option Explicit

 

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 DrawMenuBar Lib "user32"_

(ByVal hwnd As Long) As Long

 

Private Const MF_BYPOSITION = &H400&

 

Private Const MF_REMOVE = &H1000&

 

Private Sub DisableX()

   Dim hMenu As Long

   Dim nCount As Long

   hMenu = GetSystemMenu(Me.hWnd, 0)

   nCount = GetMenuItemCount(hMenu)

   Get rid of the Close menu and its separator

   Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)

   Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)

   Make sure the screen updates

   our change   DrawMenuBar Me.hWnd

End Sub

 

Private Sub Form_Load()

   DisableX

End Sub

 

Private Sub Form_Click()

We need a way out, since the X buttondoesnt work :-)

   Unload Me

End Sub 

 

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <