Solved

Tray Icons with ballooned hints

Posted on 2002-07-12
18
639 Views
Last Modified: 2010-04-04
Hi folks,

Can anyone either point me in the direction of a good free component, or perhaps some source code to allow an application to have a Tray Icon with a ballooned hint?

I want the balloon to appear when the mouse moves over the Tray Icon (similar to the current method with the old style hint).  I also want the hint to disappear after a set time, or if the balloon is clicked.

I'd also like to be able to manually display the balloon if possible.

Cheers!

Stu
0
Comment
Question by:Stuart_Johnson
  • 10
  • 7
18 Comments
 
LVL 1

Accepted Solution

by:
slavikn earned 200 total points
ID: 7149885
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7149890
Use:
traTrayIcon.ShowBalloonHint('Caption', 'Text', bitInfo, 15);
in the MouseMove event.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7151268
Hi Slavikn,

Thanks for that.  It worked great!

If anyone else finds this as a PAQ and wonders how to stop the balloon from flashing, set the OnMouseMove event to nil, then in the OnBalloonHintClick, OnBalloonHideHint and OnBalloonHintTimeout events, set the OnMouseMove event again:

procedure TMainForm.CoolTrayIcon1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  CoolTrayIcon1.OnMouseMove := nil;
  CoolTrayIcon1.ShowBalloonHint('Caption', 'Text', bitInfo, 15);
end;

procedure TMainForm.CoolTrayIcon1BalloonHintHide(Sender: TObject);
begin
  CoolTrayIcon1.OnMouseMove := CoolTrayIcon1MouseMove;
end;

Stu
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Expert Comment

by:slavikn
ID: 7151291
I am glad that I helped!
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7151292
I'd actually looked at that component before, but didn't realise that there was a timeout property for it.  I guess I should read the docos a little closer next time :)

Thanks again!

Stu
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7169306
Are you still about, Slavikn?  I need to ask another question about this tray icon component.

Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7172712
Yes Sir!!!    :-)
Feel free to ask.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7174117
Hi Slavikn,

I've got a slight problem with the tray icon.  It works well, but the problem is, the only way you can make the balloon appear is if it's forced (see code above).  This means there's no time delay (like a hint for instance).  People have complained that if they move their mouse over the icon briefly, the balloon appears - and it's annoying.

Also, under Windows XP, the balloon flashes really quickly if you leave your mouse over the icon.

Do you think you could give me a hand trying to find out how we can get this balloon to work properly?

Thanks for any help.

Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7175454
Hi again,

Sorry, must go now. I have an idea how to do it, so I will write to you tomorrow.

   Have a nice day!
      Slavikn.
0
 
LVL 1

Expert Comment

by:SJohnson
ID: 7175942
Hi,

That would be great if you could.  It's frustrating me to no end :)

Cheers!

Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7176857
Hi again,

This code seems to be long, but I couldn't make it shorter... Maybe you will find a way. If so, please post it here.

I will post the whole unit. You will see 2 declarations, one function and 2 events.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit Unit1;

interface

uses
  Forms, Classes, Windows, CoolTrayIcon;

type
  TForm1 = class(TForm)
    CoolTrayIcon1: TCoolTrayIcon;
    function ShowAfterSecs(TheTrayIcon: TCoolTrayIcon; SecCount: Byte; Par1, Par2: String; Par3: TBalloonHintIcon; Par4: TBalloonHintTimeOut): Boolean;
    procedure CoolTrayIcon1MouseExit(Sender: TObject);
    procedure CoolTrayIcon1MouseEnter(Sender: TObject);
  private
    { Private declarations }
    TempTime: Cardinal;
    ShouldShow: Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function TForm1.ShowAfterSecs(TheTrayIcon: TCoolTrayIcon; SecCount: Byte; Par1, Par2: String; Par3: TBalloonHintIcon; Par4: TBalloonHintTimeOut): Boolean;
begin
   Result := False;

   If Not ShouldShow Then Begin
      TempTime := 0;
      Exit;
   End;

   If TempTime = 0 Then
      TempTime := GetTickCount;

   If GetTickCount - TempTime > SecCount * 1000 Then
      Begin
         TempTime := 0;
         Result := True;
         ShouldShow := False;
         TheTrayIcon.ShowBalloonHint(Par1, Par2, Par3, Par4);
      End
         Else
      Begin
         Sleep(10);
         Application.ProcessMessages;
         ShowAfterSecs(TheTrayIcon, SecCount, Par1, Par2, Par3, Par4);
      End;
end;

procedure TForm1.CoolTrayIcon1MouseExit(Sender: TObject);
begin
   ShouldShow := False;
end;

procedure TForm1.CoolTrayIcon1MouseEnter(Sender: TObject);
begin
   ShouldShow := True;
   ShowAfterSecs(CoolTrayIcon1, 3, 'Title', 'Text.fertewetrwrtwrt', bitInfo, 10);
end;

end.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With regards to your second question, I don't know...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I hope this helps.
    Slavikn.
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7176863
P.S.  Of course, the "WantEnterExitEvents" property of the TrayIcon should be set to TRUE.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7176929
Hi Slavikn,

That worked really well!  Excellent!  Just give me a day to play with it and make sure it's doing what I want and I'll get back too you.

Thanks for the extremely quick response as well.  I really appreciate it!

Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7177137
Hi Stuart Johnson,

I am glad that I helped again.
I go abroad on July 29th, but
I will still answer before 28th.

   Best regards,
   Slavik N.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7181302
Hi slavikn,

That works a lot better, however there is still a little problem.  If the mouse enters the icon and then leave it, the balloon still pops up after the give time.  I'll try fixing it.  Appart from that it works much better!

Enjoy your holiday!

Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7181778
> If the mouse enters the icon and then leave it, the balloon still pops up after the give time.

I had this problem at the beginning, but I fixed it! Are you sure that you enabled the "WantEnterExitEvents"?

This should disable it (it was written above):
procedure TForm1.CoolTrayIcon1MouseExit(Sender: TObject);
begin
  ShouldShow := False;
end;

Before showing the balloon, I check that ShouldShow is set to true, otherwise, I don't show it!

Ok?
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7181945
Hi again,

Yes, the WantEnterExitEvents are definately set to true.

I already have that code set, and it still doesn't work.  If I flash the mouse over the tray icon really quickly, it still shows the balloon.

Here is the weird part.  The MouseExit event is fired AFTER the ShowAfterSecs brings up the balloon.  If I put a breakpoint after the:

  if (GetTickCount - TempTime) > (SecCount * 1000) then

line and another in the MouseExit event, the MouseExit event is fired last everytime.

Could I trouble you to email me a your example?  My email address is gtho1971@hotmail.com.  I don't know why yours is working and mine isn't.

Just as a matter of interest, does Windows actually support these balloons as alternatives to hints, or is what I'm trying to do a "hack" - it was never ment to be that way, therefore we have to force it?

Thanks for the help,


Stu
0
 
LVL 1

Expert Comment

by:slavikn
ID: 7181984
> Just as a matter of interest, does Windows actually support these balloons as alternatives to hints, or is what I'm trying to do a "hack" - it was never ment to be that way, therefore we have to force it?

Hmm, I suppose that there is no such a thing as BALLOON hint. But if you try to connect/disconnect your network you will see a balloon. So... I don't know. If there was a normal feature, we would have something like ShowBalloon...

I will send you the files very soon.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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