最新无修卖肉动漫网站:在vb里,如何将窗口右上方的“关闭”按钮设为禁用??

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 13:43:32
在vb里,如何将窗口右上方的“关闭”按钮设为禁用??

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = True
End Sub

搞定~

Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub

用API SetWindowLong 应该也可以实现

不懂
强烈建议你去看书
我记得以前看书的时候就有讲
就是那种学校的课本

复制以下代码就可以实现将窗口右上方的“关闭”按钮设为禁用
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 button'doesn't work :-)
Unload Me
End Sub