7个回答
展开全部
如果用属性设置,去掉那个东西的同时就把整个标题栏都去掉了,可行性不是很好,看看下面的:
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 Const MF_REMOVE = &H1000
Private Const SC_CLOSE = &HF060
Function Disabled(ChWnd As Long)
Dim hMenu, hendMenu As Long
Dim c As Long
hMenu = GetSystemMenu(ChWnd, 0)
RemoveMenu hMenu, SC_CLOSE, MF_REMOVE
End Function
'然后在Sub Form_Load()中加入Disabled Me.hwnd即可:
Private Sub Form_Load()
Disabled Me.hwnd
End Sub
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 Const MF_REMOVE = &H1000
Private Const SC_CLOSE = &HF060
Function Disabled(ChWnd As Long)
Dim hMenu, hendMenu As Long
Dim c As Long
hMenu = GetSystemMenu(ChWnd, 0)
RemoveMenu hMenu, SC_CLOSE, MF_REMOVE
End Function
'然后在Sub Form_Load()中加入Disabled Me.hwnd即可:
Private Sub Form_Load()
Disabled Me.hwnd
End Sub
展开全部
通过测试 ,使用关闭为灰色不可用了
去掉窗体的X
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_DISABLED = &H2&
Public Sub DisableX(Frm As Form)
Dim hMenu As Long, nCount As Long
`获得窗口系统菜单的菜单句柄
hMenu = GetSystemMenu(Frm.hwnd, 0)
`得到hMenu指定的菜单的菜单项数目
nCount = GetMenuItemCount(hMenu)
`将系统菜单的最后一个菜单项移走(最后一个菜单项是 `Close`)
Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)
`重画系统菜单
DrawMenuBar Frm.hwnd
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
DisableX Me
End Sub
去掉窗体的X
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_DISABLED = &H2&
Public Sub DisableX(Frm As Form)
Dim hMenu As Long, nCount As Long
`获得窗口系统菜单的菜单句柄
hMenu = GetSystemMenu(Frm.hwnd, 0)
`得到hMenu指定的菜单的菜单项数目
nCount = GetMenuItemCount(hMenu)
`将系统菜单的最后一个菜单项移走(最后一个菜单项是 `Close`)
Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)
`重画系统菜单
DrawMenuBar Frm.hwnd
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
DisableX Me
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这好象是去年西部杯出的题目,我做的时候看过样张,关闭按钮那里被涂过什么东西,换句话说,这其实不是标准的窗体,而是以窗体图片作为背景的没有标题栏的窗体,关闭按钮被擦掉了,我想创建这样一个窗体这对你你简单,除了他不能动,没有系统菜单.不过还有一道题目要求你能移动窗体,那你就必须使用REALEASECAPTURE和SENDMESSAGE两个API函数模仿移动了,这方面的代码网上有很多,我就不罗嗦了.至于关闭按钮无效化,就参照 jinglinggg - 大魔法师 八级 9-30 的方法.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = 1
End Sub
Cancel = 1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
能!有个类似于MaxButton的属性,记不清楚了,在窗口的属性里
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
cancel=1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询