请问怎样把每个窗体上的“最小化”、“最大化”、“关闭”三个按钮屏闭掉?

CTBOK 2003-05-09 11:02:06
我记得API可以做到的,但忘了用哪个API,又忘了怎样使用,请大家帮帮忙,谢谢
...全文
30 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bydisplay 2003-05-09
  • 打赏
  • 举报
回复
GetSystemMenu,GetMenuItemCount,DrawMenuBar,RemoveMenu函数Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
Public Const SC_CLOSE = &HF060
Public Const SC_MAXIMIZE = &HF030
Public Const SC_MINIMIZE = &HF020
Private Sub Command1_Click()
Dim hSysMenu As Long
Dim n As Long
hSysMenu = GetSystemMenu(Me.hwnd, False)
If hSysMenu Then
' 取得系统菜单中的数量
n = GetMenuItemCount(hSysMenu)
If n Then
RemoveMenu hSysMenu, n - 1, MF_BYPOSITION Or MF_REMOVE
'去掉 关闭 按钮
RemoveMenu hSysMenu, n - 2, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Me.hwnd
End If
End If
End Sub

Private Sub Command2_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_MAXIMIZE, MF_REMOVE
End Sub

Private Sub Command3_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_MINIMIZE, MF_REMOVE
End Sub

Private Sub Command4_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_CLOSE, MF_REMOVE
End Sub

Private Sub Command5_Click()
End
End Sub

gxingmin 2003-05-09
  • 打赏
  • 举报
回复
1,最简单的方法是把窗体的controlbox属性设为false

2,api:
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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Dim hSysMenu As Long, nCnt As Long
hSysMenu = GetSystemMenu(Me.hWnd, False)

If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Me.hWnd
End If
End If
lihonggen0 2003-05-09
  • 打赏
  • 举报
回复
ControlBox=False
lihonggen0 2003-05-09
  • 打赏
  • 举报
回复
http://vbboshi.myrice.com/magazine/list_11-20/mag_files/mag(14).htm

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧