Rabu, 22 Juli 2009

how to remove the Close X button in the menu

The fire Code Required

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

'
Constant value for the operation menubar
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&

Public Sub HideMenuX(Form As Form)
Dim hSysMenu As Long, nCnt As Long
hSysMenu = GetSystemMenu(Form.hwnd, False)
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then

'
Basic Menu is the number of 0 (0, 1, 2, 3 ...) RemoveMenu hSysMenu, nCnt - 1, _
MF_BYPOSITION Or MF_REMOVE

'
Remove the separator line before the close RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Form.hwnd
End If
End If
End Sub

Private Sub Command1_Click()
'
call function HideMenu
HideMenuX Me
End Sub




Tidak ada komentar:

Posting Komentar