|
-
Jan 8th, 2009, 05:16 AM
#1
Thread Starter
Addicted Member
[RESOLVED] How to disable Close and Maximize Buttons?
-
Jan 8th, 2009, 05:27 AM
#2
Re: How to disable Close and Maximize Buttons?
One way is to take them off compeltly by setting controlbox = false in the form properties.
-
Jan 8th, 2009, 05:31 AM
#3
Thread Starter
Addicted Member
Re: How to disable Close and Maximize Buttons?
that would include the minimize button.. i jaz want to disable a close or a maximize button..
-
Jan 8th, 2009, 05:57 AM
#4
Junior Member
Re: How to disable Close and Maximize Buttons?
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:
If you want to disable Maximize Button just set "MaxButton = False" in the form properties
Last edited by TheKill3r; Jan 8th, 2009 at 06:01 AM.
-
Jan 8th, 2009, 06:08 AM
#5
Hyperactive Member
Re: How to disable Close and Maximize Buttons?
Try:
in form Property ==>> Maxbutton = False
and
Code:
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
"More Heads are Better than One"
-
Jan 8th, 2009, 06:15 AM
#6
Thread Starter
Addicted Member
Re: How to disable Close and Maximize Buttons?
thanx... it works well.. :-)
-
Jan 8th, 2009, 07:11 AM
#7
Re: How to disable Close and Maximize Buttons?
If you did this, you would need Task Manager to close the application.
 Originally Posted by jp26198926
Code:
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
-
Jan 8th, 2009, 07:58 AM
#8
Re: How to disable Close and Maximize Buttons?
Disable as in don't allow the user to close the form or for what other reason?
-
Jan 8th, 2009, 08:18 AM
#9
Thread Starter
Addicted Member
Re: How to disable Close and Maximize Buttons?
 Originally Posted by dee-u
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.
-
Jan 8th, 2009, 08:24 AM
#10
Re: How to disable Close and Maximize Buttons?
So have you solved your problem?
-
Jan 8th, 2009, 08:32 AM
#11
Thread Starter
Addicted Member
Re: How to disable Close and Maximize Buttons?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|