need code to put icon in system tray 
Author Message
 need code to put icon in system tray

need code to put app in system tray..also would like to animate/change icon
when needed..any suggestion...

thanks
richard



Wed, 21 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
If you have the VB5 Pro CD, there's code to build SysTray.ocx in the
Tools\Unupprt\SysTray directory.  You can do it graphically that way and
it's simple to code.

David



Quote:
> need code to put app in system tray..also would like to animate/change
icon
> when needed..any suggestion...

> thanks
> richard




Wed, 21 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
Below you'll find an article from Knowledge Base about managing system tray.
Hope it helps...

Bye...
Serdar Aytamaner

*********************************
PSS ID Number  : Q162613
Article last modified on : 01-28-1997
PSS database name : VBWIN 4.00 WINDOWS
The information in this article applies to: Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 32-bit only,
for Windows, version 4.0

SUMMARY

One of the new features of the Windows 95 and Windows NT 4.0 user interface is the taskbar  status area. This article demonstrates
how to use Visual Basic to add, modify, and delete status or notification indicators in the taskbar status area.

MORE INFORMATION

The taskbar status area is located to the right of the Start button, and provides you with status or notification indicators about
your programs. Icons with ToolTips are typically used as indicators in the taskbar status area. The following are some examples of
how to use the taskbar status area:

- You can adjust the consumption level of your laptop's batteries by clicking a vertical graph in the taskbar status area and
adjusting it in the window that appears. The graph indicates the amount of power left in your laptop computer's batteries
- You can track your favorite stock by creating an icon that changes when your stock changes price. Click the icon to display a
chart of the stock.
- You can adjust the volume control on a multimedia device by clicking the icon and displaying more controls.

To manipulate an icon in the taskbar status area, use the Windows API function Shell_NotifyIcon in the Shell32.dll file. This
function allows you to add, modify, delete, set a ToolTip string, and send a callback message to execute mouse events. Visual Basic
does not directly accept callback messages or functions. However, there are three ways to work around this limitation:

1. The Hard Way: Create a control that accepts callbacks. Refer to the Microsoft Systems Journal article cited in the References
section of this article for a way to create a control that accepts callbacks. To create this control, you need Visual C++.
2. The Easy Way: Use a third-party control that intercepts messages, such as the Message Blaster control.
3. The Simple Way: Use a Visual Basic intrinsic control to serve as a window that accepts the reacts to the callback message. This
article contains a sample program that uses this method. With this method, you want to use an event in a control that is rarely
used. The event will be exclusively used to process the callback message.

The next section explains the Shell_NotifyIcon function and the requirements to use this function.

Shell_NotifyIcon Function

You use the Shell_NotifyIcon function to send a message to a system to add, modify, or delete an icon from the taskbar status area.
The function returns True if the message is sent successfully or False if the function is unsuccessful. The arguments of the
functions are as follows:

dwMessage: A message to execute an action. This parameter can be one of the following values:

NIM_ADD: Adds an icon to the status area.
NIM_DELETE: Deletes an icon from the status area.
NIM_MODIFY: Modifies an icon in the status area.

The values of these messages can be found in the header file, Shellapi.h.

pnid: A pointer to a NOTIFYICONDATA structure. To pass this argument to the function, create a user-defined data type called
NOTIFYICONDATA (shown later in this section) and pass this data type by value. The NOTIFYICONDATA structure contains the following
elements:

cbSize: Passes the size of the NOTIFYICONDATA data type.
Data Type: Long.
Value: Use the Len function with the variable declared as this data type as the argument.

hWnd: Handle of the window used to receive the notification message.
Data Type: Long.
Value: The hWnd property of the control used to receive this message.

uId: Identifier of the icon in the status area.
Data Type: Long.
Value: Any value within the limits of the Long data type. The sample program uses vbNull.

uFlags: Array of flags that indicate which of the other members contain valid data.
Data Type: Long
Value: Any combination of the following constants to indicate that the member of this structure is valid and will be used:

NIF_ICON: Passing this flag indicates that the value for the hIcon will be the icon that appears in the taskbar status area.

NIF_MESSAGE: Passing this flag indicates that the uCallBackMessage value will be used as the callback message.

NIF_TIP: Passing this flag indicates that the value of szTip will be used as the ToolTip for the icon in the taskbar status area.

uCallBackMessage: Identifier of the notification message sent to the window that is used to receive the messages.
Data Type: Long.
Value: The message used to identify that a mouse event has occurred within the rectangular boundaries of the icon in the taskbar
status area.

hIcon: Handle of the icon that is displayed in the taskbar status area.
Data Type: Long.
Value: The image that will be used as an icon in the taskbar status area. This can be the icon property of a control, an image from
an image control, or any icon image.

szTip: String to be used as the ToolTip text.
Data Type: Fixed-length string 64 bytes long.
Value: Any null-terminated string under 64 bytes.

The next section explains how to use this function in a sample program to manipulate icons in the taskbar status area.

The Sample Program

The sample program consists of a form containing two command buttons and the common dialog box control. When you click Add Icon, you
set the values of the NOTIFYICONDATA data type. In this data type, you set the following values:

cbSize: The length of the variable that uses the Len function.

hWnd: The handle of the window used to receive the callback messages. In the sample program, the form is used as the window to
receive the messages.

uId: The icon identifier. Although you can use any number, the sample program uses the vbNull constants.

uFlags: Array flags indicate what members of this structure are valid. The sample program uses all the flags for maximum
versatility.

uCallBackMessage: The message that is sent when mouse activity occurs on the icon in the taskbar status tray. The mouse message that
is sent maps to a mouse event in the control specified in the hWnd value. You should use a mouse message that can handle the
messages exclusively. For example, the sample program uses the WM_MOUSEMOVE message because this
message maps to the MouseMove event of the form. Rarely used in its intended form, the MouseMove event is a suitable event for this
purpose.

hIcon: The icon that is to be displayed in the taskbar status area. The sample program uses the form icon.

szTip: The ToolTip string. The string must be terminated with a null character so the vbNullChar constant is concatenated to the
string.

After setting the data, you then call the Shell_NotifyIcon function and pass the NOTIFYICONDATA along with a message to add the icon
to the taskbar status area.

When you pass the mouse pointer over the icon in the taskbar status area, the form receives the message WM_MOUSEMOVE. This message
maps to the form's MouseMove event. The X argument is the product of one of the mouse constants that indicates the mouse input (such
as a left-click, right-click, single-click, or double-click) and the TwipsPerPixelX property of the screen. The mouse input is
produced by dividing the X argument with this property. The mouse input is then used in a Select Case statement to execute a series
of instructions.

For example, when you double-click the icon, the common dialog box appears and allows you to select a different icon. The hIcon
value of the NOTIFYICONDATA data type is changed to the new icon. The Shell_NotifyIcon function is called with the new data type and
a message to modify the icon in the taskbar status area.

If you right-click the icon, you execute the InputBox function that changes the ToolTip text. The new string is null terminated with
the vbNullChar constant and the szTip value is changed to the new string. The Shell_NotifyIcon function is called with the new
NOTIFYICONDATA data and a message to modify the icon.

When you click Delete Icon or exit the application, the Shell_NotifyIcon function is called with a message to delete the icon.

Steps To Create Sample Program

1. Start Visual Basic. If it is already running, go to the File menu and click New Project.
2. Place two command buttons and a common dialog box control on Form1.
3. Copy the following code to the Form1 code window:

'Declare a user-defined variable to pass to the Shell_NotifyIcon function.
Private 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

'Declare the constants for the API function. These constants can be found in the header file 'Shellapi.h.
'The following constants are the messages sent to the Shell_NotifyIcon function to add, modify, or 'delete an icon from the taskbar
status area.

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

'The following constant is the message sent when a mouse event occurs 'within the rectangular 'boundaries of the icon in the taskbar
status area.
Private Const WM_MOUSEMOVE = &H200

'The following constants are the flags that indicate the valid members of the NOTIFYICONDATA 'data type.
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

'The following constants are used to determine the mouse input on the the icon in the taskbar status 'area.

'Left-click constants.
Private Const WM_LBUTTONDBLCLK = &H203   'Double-click
Private Const WM_LBUTTONDOWN = &H201     'Button down
Private Const WM_LBUTTONUP = &H202       'Button up

'Right-click constants.
Private Const WM_RBUTTONDBLCLK = &H206   'Double-click
Private Const ...

read more »



Wed, 21 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
Hi Serdar --

Quote:
>Below you'll find an article from Knowledge Base about managing system tray.
>Hope it helps...

The considerate thing to do is post a link, not the full text, to KB articles.

Thanks...   Karl



Wed, 21 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray


[...]
:The considerate thing to do is post a link, not the full text, to KB
articles.

But with all the server problems MS has had (are they fixed, BTW?) people
don't really know that the KB is still online.
--
Damit Senanayake
Microsoft MVP - Visual Basic
ICQ#: 6930718



Thu, 22 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
Damit --

Quote:
>But with all the server problems MS has had (are they fixed, BTW?) people
>don't really know that the KB is still online.
>--
>Damit Senanayake
>Microsoft MVP - Visual Basic

Now there's the voice of a true MS representative!  <LOL>

Later...   Karl



Thu, 22 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
I don't think you should be fighting in a public newsgroup. If you don't
beleive Damit's posts are acurrate don't respond to each of his messages
saying where it is inaccurate. You should fix his mistakes and tell him
personally through e-mail of his mistake. It is almost a constant war
between the two of you (Karl and Damit). I think this should stop. As a
Microsoft MVP you should be helping other and extending you knowledge. The
showing the lack of knowledge between yourselves.

Thank You
Farshad Hemmati


Quote:
>Damit --

>>But with all the server problems MS has had (are they fixed, BTW?) people
>>don't really know that the KB is still online.
>>--
>>Damit Senanayake
>>Microsoft MVP - Visual Basic

>Now there's the voice of a true MS representative!  <LOL>

>Later...   Karl



Thu, 22 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray
Hi Farshad --

Quote:
>I don't think you should be fighting in a public newsgroup.

It's unfortunate that one of us is characterizing this as a fight, and that you
should fall for that.  I have no personal quarrel with Damit, but I won't speak for
him on that count.

Quote:
>If you don't
>beleive Damit's posts are acurrate don't respond to each of his messages
>saying where it is inaccurate. You should fix his mistakes and tell him
>personally through e-mail of his mistake.

Sorry, but I simply don't buy that.  If you were given bad advice, wouldn't you
prefer to hear immediately that to follow it would be a waste of time, or worse yet
that it may also be potentially damaging to your system of those of your clients?  At
the least, a rapid and public correction can save not only the recipient of the
advice, but also potentially hundreds of lurkers, from following a dead end.  No, to
go private with corrections would not be in the public interest, not at all.

Quote:
>It is almost a constant war
>between the two of you (Karl and Damit). I think this should stop.

Again, this isn't a war.  But, to extend your inappropriate analogy, see below for
the only possible terms of peace.

Quote:
>As a
>Microsoft MVP you should be helping other and extending you knowledge.

I'm glad to see that you end this note with a sign of reason.  Folks should be able
to trust the advice of someone so designated.  I *care* about that.  Deeply.  And I
don't play favorites in that regard.  When I see misguided or incorrect advice
offered by an MVP, I correct it.  Similarly, I *invite*, with open arms, the same
treatment.  I truly want to know if something I post is incorrect, or not fully
thought out.  Of course, I make every attempt not to place myself in that position in
the first place.

There are many hundreds of messages each week to which I *could* respond, were I only
concerned with promoting a public image.  But I'm not.  I don't seek recognition.  I
did this long before the MVP program was established, and likely will continue for
long after the time I'm so designated.  Bottom line, I won't respond if the best I
can offer is a guess, unless someone is so desparate as to request any/all best
guesses.  Even in that case, I *clearly* label it as such.

Damit has expressed misgivings about what he percieves as a crusade against him.
That's unfortunate.  I've attempted to explain to him that all he needs to do is post
accurate information (or not post any advice at all) and everyone will leave him be.
Yet he persists with irresponsible, incorrect, and/or incomplete posts (though I see
his volume is *way* down since he realized he's now expected to be accurate).  That's
*not* what you or anyone else wants from an MVP.  Even setting aside the MVP issue,
it's still not what you expect from anyone offering advice.

The problem seems to stem from the fact that there are folks who feel that by simply
littering the newsgroups with posts, they'll be offered an MVP designation.  And,
sadly, this does seem to happen from time to time.  That's definitely not the intent,
and it's a sorry day for all when it does.

To reiterate, I bear no ill-will against Damit, but I will not sit idly by and watch
folks misled when I have the ability to help.  I hope this makes sense.

Later...   Karl



Thu, 22 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray


Fri, 19 Jun 1992 00:00:00 GMT  
 need code to put icon in system tray
Karl,


:It's unfortunate that one of us is characterizing this as a fight, and that
you
:should fall for that.  I have no personal quarrel with Damit, but I won't
speak for
:him on that count.

Thank you for not speaking for me. :) I too have something to say. At first,
I also thought (like Farshad) that this was a "fight" between you and me,
but after being whacked on the head with a "Genuine MVP Clue Stick (tm)"
I've decided to :
(a) cut down on the posts (I have to study and get a social life <vbg>)
(b) research the problem and test posted code, or indicate that it's
untested
(c) probably restrict myself to one area (what do you suggest? Anyone?)
(BTW, please take this even somewhat seriously - this isn't the OR! And,
I've removed you from the killfile - I was not thinking logically then.)

[...]
:Sorry, but I simply don't buy that.  If you were given bad advice, wouldn't
you
:prefer to hear immediately that to follow it would be a waste of time, or
worse yet
:that it may also be potentially damaging to your system of those of your
clients?  At
:the least, a rapid and public correction can save not only the recipient of
the
:advice, but also potentially hundreds of lurkers, from following a dead
end.  No, to
:go private with corrections would not be in the public interest, not at
all.

However, you could send some of the more "distasteful" comments by e-mail,
IMHO.

[...]
:To reiterate, I bear no ill-will against Damit, but I will not sit idly by
and watch
:folks misled when I have the ability to help.  I hope this makes sense.

--
Damit Senanayake
Microsoft MVP - Visual Basic
ICQ#: 6930718
http://members.xoom.com/damit/ - Only works in IE4, for now



Sun, 25 Mar 2001 03:00:00 GMT  
 need code to put icon in system tray


Fri, 19 Jun 1992 00:00:00 GMT  
 need code to put icon in system tray
Boring Git? What I/we have learned from your exchanges?

Phil

Quote:

>Hi Farshad --

>>I don't think you should be fighting in a public newsgroup.

>It's unfortunate that one of us is characterizing this as a fight, and that
you
>should fall for that.  I have no personal quarrel with Damit, but I won't
speak for
>him on that count.

>>If you don't
>>beleive Damit's posts are acurrate don't respond to each of his messages
>>saying where it is inaccurate. You should fix his mistakes and tell him
>>personally through e-mail of his mistake.

>Sorry, but I simply don't buy that.  If you were given bad advice, wouldn't
you
>prefer to hear immediately that to follow it would be a waste of time, or
worse yet
>that it may also be potentially damaging to your system of those of your
clients?  At
>the least, a rapid and public correction can save not only the recipient of
the
>advice, but also potentially hundreds of lurkers, from following a dead
end.  No, to
>go private with corrections would not be in the public interest, not at
all.

>>It is almost a constant war
>>between the two of you (Karl and Damit). I think this should stop.

>Again, this isn't a war.  But, to extend your inappropriate analogy, see
below for
>the only possible terms of peace.

>>As a
>>Microsoft MVP you should be helping other and extending you knowledge.

>I'm glad to see that you end this note with a sign of reason.  Folks should
be able
>to trust the advice of someone so designated.  I *care* about that.
Deeply.  And I
>don't play favorites in that regard.  When I see misguided or incorrect
advice
>offered by an MVP, I correct it.  Similarly, I *invite*, with open arms,
the same
>treatment.  I truly want to know if something I post is incorrect, or not
fully
>thought out.  Of course, I make every attempt not to place myself in that
position in
>the first place.

>There are many hundreds of messages each week to which I *could* respond,
were I only
>concerned with promoting a public image.  But I'm not.  I don't seek
recognition.  I
>did this long before the MVP program was established, and likely will
continue for
>long after the time I'm so designated.  Bottom line, I won't respond if the
best I
>can offer is a guess, unless someone is so desparate as to request any/all
best
>guesses.  Even in that case, I *clearly* label it as such.

>Damit has expressed misgivings about what he percieves as a crusade against
him.
>That's unfortunate.  I've attempted to explain to him that all he needs to
do is post
>accurate information (or not post any advice at all) and everyone will
leave him be.
>Yet he persists with irresponsible, incorrect, and/or incomplete posts
(though I see
>his volume is *way* down since he realized he's now expected to be
accurate).  That's
>*not* what you or anyone else wants from an MVP.  Even setting aside the
MVP issue,
>it's still not what you expect from anyone offering advice.

>The problem seems to stem from the fact that there are folks who feel that
by simply
>littering the newsgroups with posts, they'll be offered an MVP designation.
And,
>sadly, this does seem to happen from time to time.  That's definitely not
the intent,
>and it's a sorry day for all when it does.

>To reiterate, I bear no ill-will against Damit, but I will not sit idly by
and watch
>folks misled when I have the ability to help.  I hope this makes sense.

>Later...   Karl



Mon, 26 Mar 2001 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. need code to put icon in system tray

2. Putting icon into System Tray?

3. putting a icon in the system tray - HOW?

4. How to put Icon in System tray

5. How to put icons in the system tray(in vb5enterprise)

6. How can i put my application icon in system tray

7. putting Icon in system tray

8. VB or API code to put the calculator into the system tray

9. Looking for code to add an icon to win95 system tray in vb5

10. CoolHide - Help you hide/minimize window to Tray and hide icons from the system tray

11. CoolHide - Help you hide/minimize window to Tray and hide icons from the system tray

12. I need to place an icon in the system tray next to the clock

 

 
Powered by phpBB® Forum Software