Click to See Complete Forum and Search --> : Disabling maximise button
James Sadlier
July 18th, 2000, 12:15 PM
Hi folks,
I was wondering did anyone know how to disable the Maximise button on a form without disabling the Minimise button? I want to keep the form minimisable, buit I don't want the user to be able to resize it or to maximise it. Is this possible, or should I just pursue a different tack?
Thanks in advance!
July 18th, 2000, 12:56 PM
Do it at run-time:
Me.MaxButton = False
or
Click on your form and go to properties window (should be at the right-hand side of your VB screen,
otherwise press F4 to display it), Scroll down the list to find "MaxButton" and choose "False".
Hope this helps.
- Tom
James Sadlier
July 18th, 2000, 01:24 PM
Thanks, but that gave me a message "Function not available at runtime or form does not support this type of Automation". I didn't see any MaxButton property in the Properties window.
Thanks anyway though!
Rippin
July 18th, 2000, 03:49 PM
Hmmmm, you might want to check again. Make sure you click somewhere on the Form and not one of its' controls. You can tell if the form is selected because the properties window's caption will read "Properties - Form1" (or whatever the name of your form is). MaxButton shows up as a property in my version of VB.
Rippin
Nanobert
July 19th, 2000, 03:27 AM
I just read your problem and the replies and wondered:I'm not really sure, but isn't this property called "HasMaxButton"?(Think in my Version of VB it IS called like that)
Hope this is true and might help you,
Nanobert
Nanobert
July 21st, 2000, 03:51 AM
Sorry, it was just a stupid mistake.I looked it up, and, of course, the real name is "maxButton".
I think I mixed it up with another property (hasdc, or something like that).I hope I didn't confuse you too much with the stupid reply above.
Sorry,
Nanobert
RobinMiller
July 21st, 2000, 04:56 AM
Try the following -
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 Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const MF_BYPOSITION = &H400&
Public 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
' Get the form's system menu handle.
hMenu = GetSystemMenu(frm.hwnd, False)
If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITION
If remove_seperator Then DeleteMenu hMenu, 5, MF_BYPOSITION
If remove_maximize Then DeleteMenu hMenu, 4, MF_BYPOSITION
If remove_minimize Then DeleteMenu hMenu, 3, MF_BYPOSITION
If remove_size Then DeleteMenu hMenu, 2, MF_BYPOSITION
If remove_move Then DeleteMenu hMenu, 1, MF_BYPOSITION
If remove_restore Then DeleteMenu hMenu, 0, MF_BYPOSITION
End Sub
Useage is as follows on form load.
Call RemoveMenus(Me, False, True, False, False, False, True, True)
Where Boolean values relate to enable/disable respectively
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.