how to do this one?
Printable View
how to do this one?
One way is to take them off compeltly by setting controlbox = false in the form properties.
that would include the minimize button.. i jaz want to disable a close or a maximize button..
Here is a way to disable Close Button ... Put this into a Module:
VB Code:
Option Explicit Private Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, _ ByVal bRevert 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 Const MF_BYPOSITION = &H400& Public Function DisableCloseButton(frm As Form) As Boolean 'PURPOSE: Removes X button from a form 'EXAMPLE: DisableCloseButton Me 'RETURNS: True if successful, false otherwise 'NOTES: Also removes Exit Item from ' Control Box Menu Dim lHndSysMenu As Long Dim lAns1 As Long, lAns2 As Long lHndSysMenu = GetSystemMenu(frm.hwnd, 0) 'remove close button lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION) 'Remove seperator bar lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION) 'Return True if both calls were successful DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0) End Function
Then put this in Form_Load event:
VB Code:
DisableCloseButton Me
If you want to disable Maximize Button just set "MaxButton = False" in the form properties
Try:
in form Property ==>> Maxbutton = False
and
Code:Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
thanx... it works well.. :-)
If you did this, you would need Task Manager to close the application.Quote:
Originally Posted by jp26198926
Disable as in don't allow the user to close the form or for what other reason?
A command button should be used when closing the form.Quote:
Originally Posted by dee-u
So have you solved your problem?
yes...