Results 1 to 7 of 7

Thread: x button to minimize

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    3

    Question

    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.
    Rayne Bair

  2. #2
    Guest
    Try this:


    Code:
    Private Sub Form_Unload(Cancel As Integer)
        Cancel = True
        Me.WindowState = vbMinimized
    End Sub

  3. #3
    Lively Member AndySoft's Avatar
    Join Date
    Oct 2000
    Location
    Massillon, OH
    Posts
    68

    Talking Well...

    Just disable the Close button in the From's properties (duh).
    -AndySoft
    [email protected]
    [email protected] (Use the other one first!)

    I use: NASM, HTML, Perl, PHP, JavaScript, Batch, TI-Basic (TI-83+), QBasic 1.1, QuickBASIC 4.5, QuickBASIC Extended 7.1, VB-WIN 6 Ent., and the rest of Visual Studio 6 Ent. And who knows what else!

  4. #4
    Guest

    Re: Well...

    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.

  5. #5
    Guest
    There is, however, an API method that will disable only the close button.
    Code:
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    3

    Arrow

    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.
    Rayne Bair

  7. #7
    Guest
    You don't need any API for changing the function. Just use Matthew Gate's method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width