Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close (X)

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a program which puts a icon in the taskbar, but if the user clicks (X) to close the window it removes the taskbar icon.

when the user clicks (X) I just want o hide the form
 
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Select Case UnloadMode

Case vbFormControlMenu
form.hide
Cancel = 1
Case vbFormCode
Call module.del_tray
Case vbAppWindows
Call module.del_tray
Case vbAppTaskManager
Call module.del_tray
End Select

End Sub

this will do the trick .. if u unload the form with the [x] then it will hide the form and cancel the unload request .. all other will delete the icon from tray ..

/ola
 
Hiding the form will still remove the icon from the taskbar. If you want the icon to remain on the taskbar you need to programatically minimize the form. So in place of the form.hide in dgtarts code put:

Call keybd_event(VK_LWIN, 0, 0, 0)
Call keybd_event(77, 0, 0, 0)
Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)

You then need to place this in the global declarations:

Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B



Madlarry
 
humm .. i thought he ment a taskbar icon like icq or winamp(NotifyIcon). And that he wanted a function like msn-exp or sql server maneger. .. What kind of icon du u meen?

/ola
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top