Results 1 to 6 of 6

Thread: Changing the functionality of Close button

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Location
    India
    Posts
    10

    Smile Changing the functionality of Close button

    Hi everybody,
    This is my first post in this forum, and i hope that this will help me out of my problems.

    I have an application which i put in the system tray. Now i want this application to have just the Close(X) button. And on close i want to put the application back to system tray. I know that i can disable the Minimixe and Maximixe buttons. But on close how do i put it to system tray. So far what i have achieved is, I'm able to disable the Maximixe button, and with a little of code i've been able to diable the close(X) button too. And now i have just the Minimize(-) button, which on click will put the application into system tray. I want to chiave this in close(X) button instead.
    Please help me out. Code examples will be very helpful
    Saj

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    This is one way to do it:
    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.    'see if the person used the X, pressed Alt+F4, or selected Close from the control menu
    3.    If UnloadMode = vbFormControlMenu Then
    4.       'if so, do your things here that you need to do
    5.  
    6.       'stop the unloading by giving Cancel a nonzero value
    7.       Cancel = True
    8.    End If
    9. End Sub
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  3. #3
    AIS_DK
    Guest
    As fare as I recall, the close button fires the Query_Unload event for the form, and in this event you can cancel the close procedure. You can also but code here, that places the form in the sys-tray.

  4. #4
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    use this in your form queryunload event:

    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If UnloadMode = vbFormControlMenu Then '
        'The user chose the Close command from the Control menu on the form.
            pMinimizeToTray
            Cancel = True
        End If
    End Sub
    for the function pMinimizeToTray you can find examples on this site.

    hth.
    calle

  5. #5
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    Why did you just repeat exactly what I said?
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  6. #6
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    he kaverin,
    i opened this threat in a new window and after a while i answered the question.


    so it was not refreshed!

    sorry for saying the same,
    but now i think 'sajee' will believe that this is a good solution

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