another doubt --

i want my form to minimize when the user clicks the X button i wrote this code ,it minimizes the form but exits later

VB Code:
  1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  2.  
  3. Select Case UnloadMode
  4.         Case 0
  5.         Me.WindowState = vbMinimized
  6.         Exit Sub
  7. End Select
  8.    
  9. End Sub

most messengers,download managers have this feature.how is it done??