English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

要如何隱藏右上方關閉鈕?打著X的小鈕
要如何隱藏右上方關閉鈕?打著X的小鈕

2005-03-05 18:36:08 · 3 個解答 · 發問者 小傑 3 in 電腦與網際網路 程式設計

Form1.ControlBox=False
在我的VB裡失敗......
他說什麼不支援.......

2005-03-08 17:41:53 · update #1

我試想保留另外兩個按鈕,然後單獨讓關閉鈕消失.
就是只留下[縮到最小]和[放到最大]這兩個.
就單獨讓[關閉]鈕消失

2005-03-09 16:55:03 · update #2

3 個解答

如要在程式執行時使關閉鈕失效/啟用 可用API解決
新增一模組
'Module 1
Option Explicit

Public Const WM_NCACTIVATE = &H86
Public Const SC_CLOSE = &HF060&

Public Const MIIM_STATE = &H1&
Public Const MIIM_ID = &H2&

Public Const MFS_GRAYED = &H3&
Public Const MFS_CHECKED = &H8&

Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long
Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
--------------------------------------------------------------------------------------------------------
'Form1(在表單Form1上佈置Command1 及 Command2按鈕)
Option Explicit
Const xMenuID = 10& ' 用來替代 SC_CLOSE 的 Menu ID

Private Sub Command1_Click()
Dim hMenu As Long, MII As MENUITEMINFO

hMenu = GetSystemMenu(Me.hWnd, 0)

MII.cbSize = Len(MII)
MII.dwTypeData = String(80, 0)
MII.cch = Len(MII.dwTypeData)
MII.fMask = MIIM_STATE
MII.wID = SC_CLOSE

GetMenuItemInfo hMenu, SC_CLOSE, False, MII

MII.wID = xMenuID
MII.fMask = MIIM_ID
SetMenuItemInfo hMenu, SC_CLOSE, False, MII

MII.fState = MII.fState Or MFS_GRAYED
MII.fMask = MIIM_STATE
SetMenuItemInfo hMenu, MII.wID, False, MII

SendMessage Me.hWnd, WM_NCACTIVATE, True, ByVal 0&
End Sub

Private Sub Command2_Click()
Dim hMenu As Long, MII As MENUITEMINFO

hMenu = GetSystemMenu(Me.hWnd, 0)

MII.cbSize = Len(MII)
MII.dwTypeData = String(80, 0)
MII.cch = Len(MII.dwTypeData)
MII.fMask = MIIM_STATE
MII.wID = SC_CLOSE

GetMenuItemInfo hMenu, xMenuID, False, MII

MII.wID = SC_CLOSE
MII.fMask = MIIM_ID
SetMenuItemInfo hMenu, xMenuID, False, MII

MII.fState = MII.fState And (Not MFS_GRAYED)
MII.fMask = MIIM_STATE
SetMenuItemInfo hMenu, MII.wID, False, MII

SendMessage Me.hWnd, WM_NCACTIVATE, True, ByVal 0&
End Sub
試試看ㄅ.

2005-03-10 11:44:44 · answer #1 · answered by W.J.S. 7 · 0 0

程式未執行前,在表單的"屬性"內將ControlBox設為false !
沒辦法在執行時設定ControlBox !!

2005-03-08 23:06:14 · answer #2 · answered by Anonymous · 0 0

假設你的Form叫Form1。你可以用Form1.ControlBox=False

2005-03-05 20:52:33 · answer #3 · answered by yup 5 · 0 0

fedest.com, questions and answers