Solved

different HintPopupTime in same application

Posted on 2003-12-02
5
191 Views
Last Modified: 2010-07-27
Hi Experts,

I have 2 buttons on the form. I want Hint popup over first button lasted for 1 sec, but over the second button it  lasted, say, 5 sec. Q. Is it possible to have several different HintPopupTime's in same application?

Sincerely,
odissey1
0
Comment
Question by:odissey1
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
simplest sample

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  application.HintPause := 1000; //1 sec
end;

procedure TForm1.Button2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  application.HintPause := 5000; //5 sec
end;

end.

meikl ;-)
0
 
LVL 2

Author Comment

by:odissey1
Comment Utility
Hi kretzschmar,

Thank you for attention.
There is a trick in the question. I know that Delphi does not support multiple hint popup times. Two buttons, of course is just an example. In real application there are dozens of controls. Going this way I have to put MouseMove event into every control in the Application - not good. We can use mouseEnter/MouseLeave events for some particular control to set it specific HintPause, but I figured MouseLeave event is not fired always (try to move mouse fast).

So I am looking for some general idea here.

Sincerely,
odissey1
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
well,

i will take a look to the onHint-event of the application (not sure if it works),
you could use a tlist as container for the needed control-reference

will try a sample tomorrow

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
Comment Utility
what about this?
(the hinttime is stored in the tag-property of the tcontrol)


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AppEvnts, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    ApplicationEvents1: TApplicationEvents;
    procedure ApplicationEvents1ShowHint(var HintStr: String;
      var CanShow: Boolean; var HintInfo: THintInfo);
  private
    FLastHint : THintInfo;  // you may also use only a TControl as refeernce
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ApplicationEvents1ShowHint(var HintStr: String;
  var CanShow: Boolean; var HintInfo: THintInfo);
begin
  CanShow := HintInfo.HintControl = FLastHint.HintControl;
  if not CanShow then
  begin
    HintInfo.ReshowTimeout := HintInfo.HintControl.Tag;
    FLastHint := HintInfo;
  end
  else
    FLastHint.HintControl := Nil;
end;

end.

meikl ;-)
0
 
LVL 2

Author Comment

by:odissey1
Comment Utility
Hi  kretzschmar,

Thank you for help. I like your approach. I will try to utilyze not Tag's (they are already used in my application for other things), but  instead I  will try to encode ReshowTimeout into Hint string itself, like: 'This is a hint |1000' and extract all stuff on-the-fly.

Sincerely,
odissey1
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now