Click to See Complete Forum and Search --> : x button to minimize
rayne
Mar 7th, 2001, 05:09 PM
How do I get the x (close) button in the title bar to minimize the app instead of closing.
I want the user to only be able to close the program using exit on the popup menu in taskbar.
Thanks.
Try this:
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
Me.WindowState = vbMinimized
End Sub
AndySoft
Mar 7th, 2001, 06:08 PM
Just disable the Close button in the From's properties (duh).
Originally posted by AndySoft
Just disable the Close button in the From's properties (duh).
Yeah, but if you do that, you will lose the minimize and maximize buttons.
There is, however, an API method that will disable only the close button.
Private Declare Function RemoveMenu 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&
Private Sub Form_Load()
RemoveMenu GetSystemMenu(hwnd, 0), 6, MF_BYPOSITION
End Sub
rayne
Mar 8th, 2001, 08:45 AM
Is there an API method of changing the function of that button from close to minimize...can I track the message and then process my own command when it 'hears' that particular one being called?
I know you do this to change the system popup menu to your own. I just don't know exactly how to do it...I'm new to the API stuff.
Thanks.
You don't need any API for changing the function. Just use Matthew Gate's method.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.