Solved

Text in the system tray

Posted on 1998-10-14
22
307 Views
Last Modified: 2012-05-04
Is it possible to put text into the system tray like the system clock does ? If it is, then how ?  
0
Comment
Question by:Dazza051197
  • 4
  • 4
  • 3
  • +6
22 Comments
 
LVL 1

Expert Comment

by:venks
ID: 1342861
I presume you are talking about the status bar on the bottom of the screen
If it is try the following
Use ANY TRAY ICON COMPONENT and add a hint to it.You can also use popup menus with it.
For eg try the tray icon component that is avilable with RX library downloadable from Delphi Super Page
regards
venks
0
 
LVL 1

Author Comment

by:Dazza051197
ID: 1342862
I want to be able to display a clock like the system clock, but show something like the time in Australia.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342863
Hi Dazza,

 I don't think it's that easy, perhaps impossible...

 What you can do is make little icons and then combine the to the correct hour. Change every 1/60 hour the icon....

Zif.
0
 
LVL 1

Author Comment

by:Dazza051197
ID: 1342864
oh, ok, pity as it would of been nice for me to have the time in Australia then my icons then my local time.  Might get round to doing it as separate icons if I get the time. duh, get the time.!!
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342865
Dazza,

 Get the time? What so difficult on that?

Zif.
0
 
LVL 1

Author Comment

by:Dazza051197
ID: 1342866
Joke, I meant get the time as in I'm too busy, but as it was the time I needed anyway.  I guess I need double time, ie time to find the time and display the time.  But never mind, British sense of humour.
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1342867
Dazza,

You might not be able to do it in the system tray but it's easy enough to do it in the taskbar. All you need to do is run your program minimized (you can prevent the user from miximizing it) and the display the time in t the form's caption.
0
 

Expert Comment

by:bome
ID: 1342868
Gerhard, I think it should be in Application 's title property to be displayed in the task bar.

bome
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1342869
Bome,

You are 100% correct, it should be Application.Title.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1342870
hi, dazza.
hi, zif.
hi, all.

zif - it is not only, well, let's say "ugly", to show the time in the systray via combined icons. but i must admit, that was my first thought, too. especially because the clock seems to take exactly the space of two icons...

i was already wondering if ms did it the same way (you never know...)!

but on the other hand:

change the font for your desktop items.
and you'll see: the clock is affected: it's displayed in the selected font.

that makes it impossible to act properly when realizing via icons.
why?
everybody can create her/his own fonts. and surely you won't have the appropriate icons then to display the clock in this typeface.
apart from that: it's scalable...

the win32.hlp tells us that we have to use Shell_NotifyIcon. which is designed for icons. as the name says. (Edited by Computer101).

i also wanna know how to do this. let us all try to figure this out. it would be a nice component if we made it.


rex,

Black Death.
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1342871
Hi,
There must are other ways. If you spy on the SYSTRAY with spy++ or other spy-app, you will discover that the clock i a child of the SYSTRAY. So... what you have to do is add a child window to the SYSTRAY in the same way the clock does.
Sorry to say, I don't know how, but I will try and find out.
Ask this question in the MFC group and you will probably get an answer from the guys who wrote the stuff (Mike Blaszczak for instance).

/// John
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:ZifNab
ID: 1342872
interesting comments!
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1342873
:-??????????)))...
0
 

Expert Comment

by:bome
ID: 1342874
just another cent regarding putting it as an icon:
I usually have my task bar 2 units of height. This way, the icons are displayed in 2 rows, which would make it unpredictable whether 2 icons are placed next to each other.

Apart of different icon sizes, also the task bar may be moved to the left or right border...(drag it there).

So, I think the icon solution is no way.

bome
0
 

Expert Comment

by:bome
ID: 1342875
Maybe one could use a hook to get into the process of the systray program. From there the child window could be changed...

bome
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1342876
"There must are..."? - Who touched my keyboard while I was dozing off??? %-6

/// John
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342877
what about getting the handle of the taskbar, making a childwindow and do all the stuff?
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1342878
Tried that... NO success. But I guess I'm just stupid. There has to be a simple way. I scrutinized MSDN and came up with... NOTHING! Darn MS! Still think the MFC-gurus are better equipped for finding this kind of stuff in the Explorer-dung. They all seem to have elbow-long rubbergloves. ;-)

/// John
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1342879
Dazza

Here is a short program I wrote to put the time on the caption of a DC, maybe you can modify this to the systemtray as I'm sure it's a DC

this put's the time on the desktop title bar, what title bar you may ask just run this and see...

var
  Form1: TForm1;
  Dc: hDC;
implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
var
  TheTime: array[0..80] of char;
begin
  StrPCopy(TheTime, TimeToStr(time));
  TextOut(Dc, width DIV 2, 5, TheTime, StrLen(TheTime));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
DC := GetWindowDc(GetDeskTopWindow);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ReleaseDc(GetDesktopWindow, dc);
end;

Later
BoRiS
0
 
LVL 1

Accepted Solution

by:
zac earned 200 total points
ID: 1342880
Dazza,

Firstly I make three assumptions:

1) You're using delphi (doh)
2) You have access to RXlib (http://rx.demo.ru)
3) You can sucessfully put an icon on the task bar

By far and away the simplest way to perform the task of text on the taskbar is to dynamically create an icon with text in it....

The first step is to create a TBitmap of the correct size and colour depth.  Then simply use

myBitmap.Canvas.TextOut(x, y, myTime);

To write the text to the bitmap.  Now you could manually copy the data bits from the bitmap into an array create the mask and call the API CreateIcon...

However the nice guys who wrote rxlib provided us with the fantastic:

CreateIconFromBitmap(myBmp, myIcon, clWhite);
               Bitmap--^  Icon-^      ^---- Transparent Colour

Now you have an Icon with your text in it, now just change the icon on the system tray and Bobs your uncle..... You have text in the system tray.

Given the size of system tray icons the performance hit of this conversion should not be significant, and may even prove more efficient than a straight text route as the final display is buffered theorectically allowing windows to blit it straight to the screen.

I think this should solve your problem, but if you have any further questions let me know....
Enjoy..

Zac
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1342881
hey, that one's cool -
"says red zac".

zac, that one's really good!

cheerio,

Black Death.

0
 
LVL 1

Author Comment

by:Dazza051197
ID: 1342882
Yeh, neat, not what I was after but a lot better than using Icons in the taskbar.  I'll use it though so I've graded your answer.  Thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

18 Experts available now in Live!

Get 1:1 Help Now