Solved

Shell_NotifyIcon

Posted on 1998-12-18
42
376 Views
Last Modified: 2010-07-27
How can I find out, how many Icons are currently in the Shell_NotificationArea ? ( Placed there by other Programs, not by my own ).
Is there a way ?
0
Comment
Question by:Oli2
  • 18
  • 14
  • 7
  • +2
42 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Nope, there is no way, sorry...  :-(

Regards, Madshi.
0
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Sorry, Shell_NotificationArea - what is this?
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
So, may we know the original purpose of such an idea?
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Matvey, Oli2 means the icon next to the clock in the taskbar.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
DWWANG, here's the purpose: I'm creating an app, that uses a floating Menubar. Now I wanted the User to be able to "lock" it at the Win95 taskbar. But, if I don't know, how many Icons are in the Shell_NotificationArea, I don't know what I'm supposed to set the Width of my Menubar, so it doesn't mess up the view to other apps minimized. Greetings to china, by the way.

Oh well, in that case, I'll forget about the floating menubar and use a simple TNotifyIcon instead.
MADSHI: thanks. It's not the answer I hoped to read, but sometimes life's a bitch I guess.

Thanx !
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hmm. You could use 4 or 5 TNotifyIcon and paint your floating menu over all these icons. Would mean some work...

Regards... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Madshi: That's what I thought at first, too. But: if I set my Width to let's say 30, and it takes let's say 4 Icons to have the same Width, how do I know, how many Icons my app has to add ( meaning: IconsAllreadyThere(x) + IconsFromMyApp(y) = 4 )
if I don't know this => (x), then there's no way.
If the user has a soundblaster active and the monitor-icon in the tray and maybe he is online, then (x) would be => 3
if nothing of this is true, then (x) => 0

Got it ?
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Oli,

no, didn't got it!
It seems that you want to overwrite the existing icons. Why that? Why not simply adding 4 icons? Then the user would see the soundblaster icon and the monitor icon and the modem icon and your 4 icons. Then you should not overwrite your 4 icons (you can't do that, because you don't know where they are). You could put your menu item in the icons themselfs. E.g. show "Me" in the first icon, "nu" in the second icon, "it" in the third icon and "em" in the forth. Of course it's not so easy to split a menuitem into several icons. But that's another problem...

Regards... Madshi.
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
First, thanks for your greetings to China, Oli2 :-)

However, can't get this problem solved, maybe some day I can get back to this topic because of having found some thing new from Internet.

Regards,
Wang
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
okay, madshi, dann halt in deutsch ;-)

Also, meine floating menubar sollte rechts unten "auf" der Win95 Taskleiste verankert werden. Es sollte sozusagen die normale Shell_NotificationArea verdecken. (Nicht mehr, nicht weniger) Dazu müsste ich aber wissen, wie breit die Shell_NotificationArea überhaupt ist. Und dazu wiederum müsste ich wissen, wie viele Icons da drin sind.

Klingeling ?

Gruß, Oli

0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Wang: If you ever find a solution, let us know. I changed my app into a normal ShellNotifyIcon app, so it's not that important anymore, but still it would be interesting to know.

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi Oli,

schon klar, was Du meinst. Aber wieso willst Du Deine MenuBar unbedingt ÜBER die NotificationArea malen? Warum nicht die MenuBar in 4 Icons aufsplitten und DURCH die Taskbar malen lassen? Also ganz rechts die Uhr, daneben das Lautsprecher-Symbol und dann 4 Icons für Deine MenuBar. Natürlich würde die MenuBar dann zusätzlich zu den Icons Platz wegnehmen, aber wäre das denn so schlimm? Das Problem ist nur, das Du ja dann die MenuBar in einzelne Icons aufsplitten müßtest... Diese Idee muß Dir ja nicht gefallen, wäre nur schön, wenn Du verstehen würdest, was ich überhaupt meine...  :-)

Grüße... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Madshi: Ich verstehe was Du meinst. Das Problem war, daß ich es gerade so nicht machen wollte. ( Weil es so ja jeder macht :-)) )  Aber jetzt ist es sowieso eine stinknormale ShellNotifyIcon - app geworden, mit einem stinknormalen Popupmenu ( wie Du ja wissen müsstest => SetForegroundWindow, Dein Tip ).
Bin mittlerweile mit dieser Lösung einigermaßen zufrieden !

Gruß, Oli
0
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
Makes me wish I kept on with German in University :-)

0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
rwilson: makes me wish my english would be good enough to explain my probs understandable ;-)
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Raymond, sorry for writing the last comments in German. It was somehow difficult to write what we've written in English. However it was just a repetition of what I've written in English some comments before...  :-(

Oli, na wenn Du zufrieden bist...  :-)
Hmmm. I've another idea - that means if you still want to realize your original idea. You could add a taskbar icon then simulate mouse messages to the taskbar window by using PostMessage(taskbarWnd,WM_MOUSEMOVE,...). So you could try to find the pixel location of the newly added icon. Because the window procedure of your icon will give you your simulated events back. Would that help?
Or should I stop thinking about this question, since you're satisfied with the "simple single taskbar icon" solution?

Regards... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
rwilson: sorry again for writing in german :-(

Madshi: I think, this wouldn't work out, since the newest Icon is not always placed to the left side of the NotificationArea. Sometimes, it gets placed right into the middle.
At least, that's what I experienced.

Shall you stop thinking about this question ?
I don't know. I changed my application to a single icon app. That doesn't mean I'm not interested in an answer anymore. If somebody finds one, he'll get the points. Simple as that !  :-)

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hmmm. Are you sure that sometimes the icons are placed into the middle? I always thought they would always be placed in the left...

Regards... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
I'm sure !
I have a CreativeLabs soundcard installed. The Icon ( yellow speaker ) is shown on the left side. Then I add a new Icon to the ShellNotificationArea and .... it's placed between the time and the speaker. Also: if I receive a mail, the Icon "New Mail" always appears next to the time. So it moves all other icons to the left. I wonder, how Windows controls this. Maybe by the TNotifyIonData.uID ? I should try this sometime.

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hmmm. You're right. The eMail icon is always on the right side...  :-(

Regards, Madshi.
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Seem the topic is changed, right?

But if you are wondering how the icon can be placed just left to the time label(i.e. "moves all other icons to the left"), here is an example: http://vcl.vclxx.com/DELPHI/D32FREE/TBICON.ZIP

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
Hey, I have no problem with you guys writing in German. I was able to follow the gist of what you were saying, its just the holes in my German kept tripping me up!

Cheers,

Raymond.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Raymond => maybe a little more interest in German and a little less interest in the female students back then at the university would have saved you from "my German kept tripping me up"  ;-))

dwwang => your example should be very interesting. If there's a way to make sure the icon's placed to the very right, then there's got to be way to make sure the icon gets placed to the very left also. Unfortunately, I keep on trying to download the tbicon.zip, but it always stalles at about 30% progress. I'll keep on trying.

madshi => told you so... :-)

Greetings, Oli
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Hi, Oli2, if still have problem downloading, You can try this alternate site:

http://delphi.nease.net/DELPHI/D32FREE/TBICON.ZIP

I tried it both in Win95 and Win98, both D3 and D4, gives the same result, the position is just left to the taime label.

Do you mean this will solve your problem? :-)
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
dwwang, the download from the alternate site worked out.

I'm getting really confused. I looked into the code and found nothing unusual.
Then I wrote a test-application and - it alway places the Icon right next to the time label.

On my Computer at home, it doesn't do that, it places the icon into the middle !

What I'm really after now is: how can I get my icon placed to the outer left side of the NotificationArea, no matter how many icons are already placed there.
I tried the TNotifyIconData.uID, but that doesn't seem to have any influence.
Well I'll keep on trying...

Greetings, Oli

0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Yes, that's what I'm wondering too, I can't see any extra code but the icon is at right most.
Keep trying then, good luck! :-)

Season's Greeting from China!

Wang
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
After doing some testing, it seems I was wrong when I said, my Computer at home behaves different.
New Icons always get placed next to the time label. ( and move existing Icons to the left )
Unfortunately !!!  Otherwise, I could take madshi's advice and get the size of the NotificationArea by placing my Icon to the outer left side and then check the screen position.

So it seems, this is no way to solve my probs either.

Anymore suggestions ?

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
:-)

My ideas are becoming more and more ugly...  :-)

You could set a systemwide SetWindowsHookEx hook (in a dll :-() and then simulate mouse move messages over the taskbar again. So as long as the hook receives your simulated messages there are taskbar icons under your "mouse".

Regards... Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
that's quit some hard tobacco, madshi....
but you're right, it should work.
I'll think about it.

Greetings, Oli
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
To Dwwang and Raymond:

My question was: "how can I find out, how many icons are allready placed in the NotificationArea".
Now it seems to me that Madshi came up with an accepable idea ( set a systemwide SetWindowsHookEx hook and then simulate mouse move messages over the taskbar )
To me it seems, this is the only way to solve it.

I allready changed my application into a normal NotifyIcon application, but that's irrelevant.
Madshi found an answer and I think, he should get the points.
What do you guys think about it ?

Greetings, Oli

0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Hi, Oli

I never mean to answer this question, just feel interesting hence enter the discussion :)

Greetings,
Wang
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Wang: Does that mean giving the points to Madshi would be okay to you ?

Greetings, Oli
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Yes, of course :-)

Greetings,
Wang
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Thanx, Wang...  :-)

Hi Oli,
hmm. I think if you don't want to implement my idea (you don't really want to do this hack, do you?), you should just delete the question...    :-)

Regards, Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Madshi: Why should I delete the question? You came up with an answer, so you should get the points.
I wouldn't like to have somebody ask me a question about implementing a thread into a thread that is implemented in a thread and offering 800 Pts. for the answer and then, when I come up with the answer, to read something like "sorry, I'm to lazy for all this code. I'll just delete the question."
okay, the example does not really fit, but you get the idea of what I mean.

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
OK then, that's quite fair from you...  :-)

Thank you, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi Oli,

now I earn my points!!! I've the perfect solution for you:

function GetTrayRect : TRect;
begin
  GetWindowRect(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'TrayNotifyWnd',nil),result);
end;

Quite easy, isn't it!?

Regards, Madshi.
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Hey, Madshi, Congratulations !!
This is the easy-one-line-function I was looking for :-)
I reject the old answer, so you can post this one as the new one.
(Will help other help-seeking people - I mean they don't have to read through all the comments before finding the right answer. )

Greetings, Oli
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Hey, Madshi, even more congratulations !!
noticed you finally show up in the top 15...
What took you so long ?  ;-)

Greetings, Oli
0
 
LVL 20

Accepted Solution

by:
Madshi earned 150 total points
Comment Utility
Hi Oli,

function GetTrayRect : TRect;
begin
  GetWindowRect(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'TrayNotifyWnd',nil),result);
end;

:-)))  With your points I'll go to number 14...   :-)
If you want me to boost to Nr. 1 you may (of course) give me 26.000 points. So the my hiscore speed depends on you...   :-)

Regards, Madshi
0
 
LVL 1

Author Comment

by:Oli2
Comment Utility
Hi, Madshi !
Sorry to say, but I havn't got 26.000 Pts. left to spent. :-)
You'll make your way up to the top anyway.

Greetings, Oli
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
You don't have 26.000 points? Oooohhhh.....   :-(
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now