ทำให้มันหายไปไม่ได้แต่ทำให้ กด ไม่ได้ครับ( Disable)
ใช้ Code นี้ครับ
ผมไม่เข้าใจนะครับ ลอกมาจาก Api-Guide ที่อาจารย์อรวีร์แนะนำครับ
ผม ยกเลิก ไปหลายบรรทัด ก็ยังทำงานได้อยู่
เลยไม่รู้ว่าแต่ละบรรทัดหมายความว่าอะไร
รบกวนผู้รู้ แนะนำด้วยนะครับ
จะได้ประยุกต์ใช้ได้ในโอกาศต่อไปครับ
ขอบคุณมากมากครับผม
Code:
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
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
Private Sub UserForm_Initialize()
Dim hSysMenu As Long, nCnt As Long
Dim Hwnd As Long
' Get handle to our form's system menu
' (Restore, Maximize, Move, close etc.)
Hwnd = FindWindow("ThunderDFrame", "UserForm2")
hSysMenu = GetSystemMenu(Hwnd, False)
'If hSysMenu Then
'Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)
' If nCnt Then
' Menu count is based on 0 (0, 1, 2, 3...)
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
'RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
'DrawMenuBar lHwnd
' Force caption bar's refresh. Disabling X button
' Me.Caption = "Try to close me!"
' End If
'End If