Kode untuk mendisable button x atau tombol close pada MDI form - Di bawah ini merupakan cara menghilangkan button 'x' atau tombol close pada MDI Form.
READ MORE - VB6 Code - Disable Button X atau Tombol Close Pada MDI
'simpan kode di bawah pada moduleContoh penggunaan kode di atas:
Option Explicit
Private Declare Function DeleteMenu Lib "user32" ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Dim hMenu As Long
Public Sub RemoveMenus(frm As Form, Optional brestore As Boolean, Optional bmove As Boolean, Optional bsize As Boolean, Optional bminimize As Boolean, Optional bmaximize As Boolean, Optional bseperator As Boolean, Optional bclose As Boolean)
hMenu = GetSystemMenu(frm.hwnd, False)
If bclose Then DeleteMenu hMenu, 6, MF_BYPOSITION
If bseperator Then DeleteMenu hMenu, 5, MF_BYPOSITION
If bmaximize Then DeleteMenu hMenu, 4, MF_BYPOSITION
If bminimize Then DeleteMenu hMenu, 3, MF_BYPOSITION
If bsize Then DeleteMenu hMenu, 2, MF_BYPOSITION
If bmove Then DeleteMenu hMenu, 1, MF_BYPOSITION
If brestore Then DeleteMenu hMenu, 0, MF_BYPOSITION
End Sub
'simpan kode di bawah pada MDI Form.
Option Explicit
Private Sub MDIForm_Load()
'nilai true untuk remove, sesuaikan kodenya!
RemoveMenus Me, , , , , , True, True
End Sub