Results 1 to 5 of 5

Thread: The CLOSE (X ) BUTTON ON THE TITLE BAR PLEASE HELP

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    I know if the person clicks the x it is in the code form_unload but here is the thing when someone clicks the x it only kils that one form I want the rest to be killed too so I put unload all the forms under the form unload like this:
    unload form1

    but the thing is sometimes in the code i have it so the form unloads because of something else and when that happens it will kill them all when I don't want it to. I remember seeing something liek this maybe..
    pirvate sub form_unload()
    If vb?????? = true then
    unload form1
    end if
    end sub

    does anyone know how to do this?
    then


    ------------------
    Sincerely,
    Chris
    :-) ;-)
    just have fun out there and live life to the fullest while it is still here
    Email [email protected]


  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    in the form_unload put:
    Code:
        End
    You may want to unload the other forms because using END does not always clear the forms from memory.

    ------------------
    DiGiTaIErRoR
    VB, QBasic, Iptscrae, HTML
    Quote: There are no stupid questions, just stupid people.

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    I know end ends it. But in my code somewhere else I have this

    private sub command1_click()
    unload form1
    form2.show
    end sub

    with that there it will end the program cause under the form_unload I had
    unload form1
    unload form2
    unload form3
    etc
    see what i mean??




    ------------------
    Sincerely,
    Chris
    :-) ;-)
    just have fun out there and live life to the fullest while it is still here
    Email [email protected]


  4. #4
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    I think I got it. Basically, you can't, because the computer doesn't know if the user is clicking the X to get rid of the program, or clicking the X to get rid of the form. You could try making the main form invisible instead of unloading it.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    It sounds like you should think about redesigning your project, but if you want a form to close only if the user click the "X", then use this as that form's QueryUnload event.
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
        Select Case UnloadMode
            Case vbFormControlMenu
                ' The user chose the Close command from the Control menu on the form
    '        Case vbFormCode
    '            ' The Unload statement is invoked from code.
    '        Case vbAppWindows
    '            ' The current Microsoft Windows operating environment session
    '            ' is ending.
    '        Case vbAppTaskManager
    '            ' The Microsoft Windows Task Manager is closing the application.
    '        Case vbFormMDIForm
    '            ' An MDI child form is closing because the MDI form is closing.
    '        vbFormOwner
    '            ' A form is closing because its owner is closing.
            Case Else
                Cancel = True
        End Select
    
    End Sub
    What happens here is that when the user clicks the "X", UnloadMode equals vbFormControlMenu and VB allows the form to unload. Any other value for UnloadMode sets Cancel to True which stops the unload. I left in commented examples of all the other possible form-unload scenarios.

    ------------------
    Marty
    COGITO EGGO SUM
    I think; therefore I am a waffle.

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