前几天,我们在调试代码的过程中我发现,我们的画图板窗体上关闭按钮不可用,这是什么原因呢,查了关于窗体得属性只有控制Maxbutton和MinButton,而没有控制关闭的,我们找来了师傅,在百度上查了又查终于找到答案了!
这是相关代码:
PrivateDeclare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,ByVal bRevert As Long) As Long
PrivateDeclare Function RemoveMenu Lib "user32" (ByVal hMenu As Long,ByValnPosition As Long,ByVal wFlags As Long) As Long
PrivateConst MF_REMOVE = &H1000
PrivateConst SC_CLOSE = &HF060
FunctionDisabled(ChWnd As Long)
DimhMenu,hendMenu As Long
Dim c AsLong
hMenu =GetSystemMenu(ChWnd,0)
RemoveMenuhMenu,SC_CLOSE,MF_REMOVE
EndFunction
'然后在SubForm_Load()中加入Disabled Me.hwnd即可:
PrivateSub Form_Load()
DisabledMe.hwnd
End Sub
这让我很惊奇,一个小小的关闭按钮,怎么还用API函数来控制呢,看来我的学习还不够,连冰山一角都没学到,API好神秘啊.功能也那么强大,什么时候我才能运用自如了.
我得努力!!!
通过这个小问题的学习,我悟出,遇事不要慌,不要先在心理上给自己打退堂鼓,这才是对待问题的良策呀!!!