vb表單 右上角的XX要怎麼關閉
項最小化有minbutton = false
最大化有maxbutton = false
或使用固定框線
那關閉視窗的XX鈕要怎麼關閉??
是要改屬性??
還是要在form_load下指令??
2006-08-11 22:23:46 · 3 個解答 · 發問者 whatai 2 in 電腦與網際網路 ➔ 程式設計
call win API 即可
1.先開啟一個Form
2.加入以下程式碼
Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function AppendMenu Lib "User32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Private Declare Function GetMenuString Lib "User32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_NCLBUTTONDBLCLK = &HA3
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Const MF_STRING = &H0&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060
Private hMenu As Long
Private CloseStr As String '記錄Close MenuItem的字串
Private Sub Form_Load()
hMenu = GetSystemMenu(Me.hwnd, 0)
CloseStr = String(255, 0)
'SC_CLOSE指的便是"關閉"的那一個MenuItem ID
Call GetMenuString(hMenu, SC_CLOSE, CloseStr, 256, MF_BYCOMMAND)
CloseStr = Left(CloseStr, InStr(1, CloseStr, Chr(0)) - 1)
Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
End Sub
因為沒有離開功能鈕
再來你就要自己寫一個離開鈕
2006-08-12 00:43:16 · answer #1 · answered by ㄚ旺 5 · 0⤊ 0⤋
如果是要把 最大、最小、關閉 都不顯示出來的話,只要把 Controlbox 屬性設為 false 即可.
2006-08-12 08:52:28 · answer #2 · answered by ? 7 · 0⤊ 0⤋
丫旺的答案非常不錯, 可是如果你想用簡單的方法,
可以將form1中的BorderStyle屬性設定為0 - None即可
這樣是連Caption那一列整個也都不見, 當然移動視窗也會成問題,
不過, 你可以自行設計很多東西... 也是可以考慮的方式...
2006-08-12 03:55:56 · answer #3 · answered by 樂財 5 · 0⤊ 0⤋