Cara penggunaan : Copy paste code ini ke form code kemudian jalankan, terlihat bahwa close X nya sudah disable
Option ExplicitPrivate Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As LongPrivate Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Const MF_BYPOSITION = &H400&Private ReadyToClose As BooleanPrivate Sub RemoveMenus(frm As Form, _remove_restore As Boolean, _remove_move As Boolean, _remove_size As Boolean, _remove_minimize As Boolean, _remove_maximize As Boolean, _remove_seperator As Boolean, _remove_close As Boolean)Dim hMenu As Long' Mengambil dari menu handle pada formhMenu = GetSystemMenu(hwnd, False)If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITIONIf remove_seperator Then DeleteMenu hMenu, 5, MF_BYPOSITIONIf remove_maximize Then DeleteMenu hMenu, 4, MF_BYPOSITIONIf remove_minimize Then DeleteMenu hMenu, 3, MF_BYPOSITIONIf remove_size Then DeleteMenu hMenu, 2, MF_BYPOSITIONIf remove_move Then DeleteMenu hMenu, 1, MF_BYPOSITIONIf remove_restore Then DeleteMenu hMenu, 0, MF_BYPOSITIONEnd SubPrivate Sub cmdClose_Click()ReadyToClose = TrueUnload MeEnd SubPrivate Sub Form_Load()' Menghapus sistem close pada menu separator.RemoveMenus Me, False, False, _False, False, False, True, TrueEnd Sub' Batalkan jikaReadyToClose dalam modus false.Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)Cancel = Not ReadyToCloseEnd Sub
Baca juga beberapa artikel terkait berikut ini :
0 komentar:
Posting Komentar