Solved

Shell_NotifyIcon

Posted on 1998-12-18
42
378 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
ID: 1351852
Nope, there is no way, sorry...  :-(

Regards, Madshi.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1351853
Sorry, Shell_NotificationArea - what is this?
0
 
LVL 4

Expert Comment

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

Expert Comment

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

Author Comment

by:Oli2
ID: 1351856
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
ID: 1351857
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
ID: 1351858
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
ID: 1351859
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
ID: 1351860
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
ID: 1351861
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
ID: 1351862
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
ID: 1351863
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
ID: 1351864
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
ID: 1351865
Makes me wish I kept on with German in University :-)

0
 
LVL 1

Author Comment

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

Expert Comment

by:Madshi
ID: 1351867
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
ID: 1351868
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
ID: 1351869
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
ID: 1351870
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
ID: 1351871
Hmmm. You're right. The eMail icon is always on the right side...  :-(

Regards, Madshi.
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1351872
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1351873
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
ID: 1351874
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
ID: 1351875
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
ID: 1351876
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
ID: 1351877
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
ID: 1351878
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
ID: 1351879
:-)

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
ID: 1351880
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
ID: 1351881
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
ID: 1351882
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
ID: 1351883
Wang: Does that mean giving the points to Madshi would be okay to you ?

Greetings, Oli
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1351884
Yes, of course :-)

Greetings,
Wang
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1351885
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
ID: 1351886
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
ID: 1351887
OK then, that's quite fair from you...  :-)

Thank you, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1351888
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
ID: 1351889
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
ID: 1351890
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
ID: 1351891
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
ID: 1351892
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
ID: 1351893
You don't have 26.000 points? Oooohhhh.....   :-(
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Memory leak using records in a TVirtualStringTree 11 109
add combobox item based on numbers 9 122
Delphi - replicating a form 8 62
Delphi: Connect to running MS Outlook 4 47
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

19 Experts available now in Live!

Get 1:1 Help Now