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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows shutting down

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a VB program that gets put in the task bar. The problem is that when you try and shut the computer down it won't until you remove the VB from the taskbar!!!

Tim
 
I take it the thing in the task bar is a loaded form??

Is there code in the queryunload event of that form that sets cancel to true??

 
in Bas Module I have this
Code:
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

Public Type NOTIFYICONDATA
    
    cbSize As Long
    hwnd As Long
    uID As Long
    uFlags As Long
    uCallbackMessage As Long
    hIcon As Long
    szTip As String * 64

End Type

Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const NIM_MODIFY = &H1

Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4

Public Const WM_MOUSEMOVE = &H200
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDOWN = &H204

Global TrayIcon As NOTIFYICONDATA


Public Sub AddToTray(frm As Form, ToolTip As String, Icon)

    On Error Resume Next
    TrayIcon.cbSize = Len(TrayIcon)
    TrayIcon.hwnd = frm.hwnd
    TrayIcon.szTip = ToolTip & vbNullChar
    TrayIcon.hIcon = Icon
    TrayIcon.uID = vbNull
    TrayIcon.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
    TrayIcon.uCallbackMessage = WM_MOUSEMOVE
    
    Shell_NotifyIcon NIM_ADD, TrayIcon

End Sub

Public Sub RemoveFromTray()

    Shell_NotifyIcon NIM_DELETE, TrayIcon

End Sub
and in form I have this:
Code:
Private Sub Form_Load()
      'Me=Form, "unpack"=traytip, Me.Icon=Icon used for app     
    AddToTray Me, "UnPack", Me.Icon

End Sub

Private Sub Form_Unload(Cancel As Integer)
'releasing objects from memory
    Set objData = Nothing
    RemoveFromTray
    Unload Me
    Unload frmMain 
End Sub
 
Is there code in the queryunload event of that form that sets cancel to true??

yep that is correct!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top