以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何使项目的最小化与关闭按钮失效  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=88076)

--  作者:dragonfang
--  发布时间:2016/7/26 16:42:00
--  如何使项目的最小化与关闭按钮失效
如何使项目的最小化与关闭按钮失效,仅仅自己设定的退出按钮才可以退出项目
--  作者:大红袍
--  发布时间:2016/7/26 16:44:00
--  

禁用关闭按钮,参考

 

全局代码

 

Public Const SC_CLOSE As Integer = &Hf060
Public Const MF_ENABLED As Integer = &H0
Public Const MF_GRAYED As Integer = &H1
Public Const MF_DISABLED As Integer = &H2

<DllImport("user32.dll", EntryPoint := "GetSystemMenu")> _
Public Function GetSystemMenu(hWnd As IntPtr, bRevert As Integer) As IntPtr
End Function

<DllImport("User32.dll")> _
Public Function EnableMenuItem(hMenu As IntPtr, uIDEnableItem As Integer, uEnable As Integer) As Boolean
End Function

 

调用代码

 

Dim hMenu As IntPtr = GetSystemMenu(basemainform.Handle, 0)
EnableMenuItem(hMenu, SC_CLOSE, (MF_DISABLED + MF_GRAYED) Or MF_ENABLED)


--  作者:大红袍
--  发布时间:2016/7/26 16:45:00
--  

隐藏最小化,参考

 

basemainform.MinimizeBox = False
basemainform.MaximizeBox = False