إزالة زر X وعنصر إغلاق من قائمة النظام للنافذة
Amjad Moustafa :: VB6 :: Codes :: Windows
صفحة 1 من اصل 1
إزالة زر X وعنصر إغلاق من قائمة النظام للنافذة
'===================================================
'Sub: RemoveSysMenuX
'Description: Removes the "X" button and the Form Close Menu from a window's system menu
'Where to place code: Module, Call it in the form's Form_Load() Event
'Notes: Set frm to the name of the form you want to disable the "X" button and Form Close Menu on
'
'http://www.littleguru.com
'==================================================
Public Declare Function DrawMenuBar& Lib "user32" (ByVal hwnd As Long)
Public Declare Function GetMenuItemCount& Lib "user32" (ByVal hMenu As Long)
Public Declare Function GetSystemMenu& Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long)
Public Declare Function RemoveMenu& Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long)
Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000
Public Sub RemoveSysMenuX(frm As Form)
Dim hMenu As Long
Dim lngMnuCount As Long
hMenu = GetSystemMenu(frm.hwnd, 0)
lngMnuCount = GetMenuItemCount(hMenu)
RemoveMenu hMenu, lngMnuCount - 1, MF_REMOVE Or MF_BYPOSITION
RemoveMenu hMenu, lngMnuCount - 2, MF_REMOVE Or MF_BYPOSITION
DrawMenuBar frm.hwnd
End Sub
'Sub: RemoveSysMenuX
'Description: Removes the "X" button and the Form Close Menu from a window's system menu
'Where to place code: Module, Call it in the form's Form_Load() Event
'Notes: Set frm to the name of the form you want to disable the "X" button and Form Close Menu on
'
'http://www.littleguru.com
'==================================================
Public Declare Function DrawMenuBar& Lib "user32" (ByVal hwnd As Long)
Public Declare Function GetMenuItemCount& Lib "user32" (ByVal hMenu As Long)
Public Declare Function GetSystemMenu& Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long)
Public Declare Function RemoveMenu& Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long)
Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000
Public Sub RemoveSysMenuX(frm As Form)
Dim hMenu As Long
Dim lngMnuCount As Long
hMenu = GetSystemMenu(frm.hwnd, 0)
lngMnuCount = GetMenuItemCount(hMenu)
RemoveMenu hMenu, lngMnuCount - 1, MF_REMOVE Or MF_BYPOSITION
RemoveMenu hMenu, lngMnuCount - 2, MF_REMOVE Or MF_BYPOSITION
DrawMenuBar frm.hwnd
End Sub
Amjad Moustafa :: VB6 :: Codes :: Windows
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى