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

Changing System Tray Icon!! Pls Help 1

Status
Not open for further replies.

Fori

Programmer
Jun 18, 2003
84
MT
Hi All

I've written some code that would put my application in system tray!! Now i would like to change the icon everytime a process starts!! how can i do this?? any help!!

Thanks
Nick
 
I've never written applications for the System Tray but to change an aplications icon you go into project and properties and change it in there. I assume that would change the icon which appears in your system tray also.

Mark

The key to immortality is to make a big impression in this life!!
 
Use Shell_NotifyIcon to send a NIM_MODIFY message, with the appropriate members of NOTIFYICONDATA set
 
sorry strongm but i have no idea what u're talking about..haven't much experience using api and systemtray so if u can explain a little slower, pls!!

thanks nick
 
>I've written some code that would put my application in system tray

From the above I assumed you would already be familiar with Shell_NotifyIcon. Is this not the case?
 
yes but since i've searched for the code on the internet i have no clue what it does ..... only through logic i can understand!!

Thanks strongm for your help....

I have this code which upon running it works perfectly!! I have a timer that runs code every 5min... while running this code i would like it to change icon! but nothing happens!! this is the code i have and used


Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const HWND_TOPMOST = -1

Public nid As NOTIFYICONDATA

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

Private Sub Form_Resize()
With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = Me.Caption & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub


Hop this clarifies the situatin!!

thanks once again
Nick

 
Ok, given the code you already have, the following is the sort of thing you need to do:
[tt]
' In this example I am simply getting an icon handle from one of the images in
' an ImageList control. Your icon handle may come from somewhere else, eg a form's icon
' (as it does in your posted code for the form's resize event)
With nid
.hIcon = ImageList1.ListImages(1).ExtractIcon.Handle
End With
Shell_NotifyIcon NIM_MODIFY, nid
 
Sorry i know what was the problem...laziness! i've figured it out and its quite similar to yours!!

Thanks alot for your help strongm (its not the first time you helped me out!!)

Tahnks
Nick
 
Fori
You might consider giving the man a STAR for his helpful/expert post! I notice you haven't given any stars yet. It's not painful, just click on the 'Mark this post as a helpful/expert post' link at the bottom of the appropriate answer.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Sorry...you're definetly right!! but on the other hand i should award all you great programmers a star for helping me out!!

Tahnks
Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top