Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-03

Application.OnShowHint problem

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frank Poretzky

Hi!

A method

| procedure TFormTest.DoAppOnShowHint( var HintStr: String;
|                                      var CanShow: Boolean;
|                                      var HintInfo: THintInfo);
|   begin
|     CanShow := true;
|     HintStr := HintStr + ' - Modified';
|   end;

assigned to Application.OnShowHint is called neither with

| {$Mode ObjFPC}
| {$H+}
...
| procedure TFormTest.DoFormOnCreate( Sender: TObject); ...
| Application.OnShowHint := @DoAppOnShowHint;

nor with

| {$Mode Delphi}
| {$H+}
...
| procedure TFormTest.DoFormOnCreate( Sender: TObject); ...
| Application.OnShowHint := DoAppOnShowHint;

It's always the original Hint string of the respective control which shows up.

What may be wrong?

Lazarus 1.0.14 / FPC 2.6.2 / SVN Rev 43446 / i386-win32-win32/win64

Thanks

Frank

Reply by email

Graeme Geldenhuys
to Frank Poretzky
Frank Poretzky wrote 8 lines
| procedure TFormTest.DoAppOnShowHint( var HintStr: String; | var CanShow: Boolean; | var HintInfo: THintInfo); | begin | CanShow := true; | HintStr := HintStr + ' - Modified'; | end;

Does the DoAppOnShowHint() actually execute? If you set a breakpoint in that method, does it get triggered?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Frank Poretzky
to Graeme Geldenhuys

Hi Graeme,

you wrote 13 lines
On 2014-03-30 04:45, Frank Poretzky wrote: > > | procedure TFormTest.DoAppOnShowHint( var HintStr: String; > | var CanShow: Boolean; > | var HintInfo: THintInfo); > | begin > | CanShow := true; > | HintStr := HintStr + ' - Modified'; > | end; Does the DoAppOnShowHint() actually execute? If you set a breakpoint in that method, does it get triggered?

No, it doesn't, which exactly is my problem.

Frank

Reply by email

Flávio Etrusco
to Frank Poretzky
Frank Poretzky wrote 22 lines
Hi Graeme, on Sun, 30 Mar 2014 10:09:31 +0100, you wrote: >On 2014-03-30 04:45, Frank Poretzky wrote: >> >> | procedure TFormTest.DoAppOnShowHint( var HintStr: String; >> | var CanShow: Boolean; >> | var HintInfo: THintInfo); >> | begin >> | CanShow := true; >> | HintStr := HintStr + ' - Modified'; >> | end; > > >Does the DoAppOnShowHint() actually execute? If you set a breakpoint in >that method, does it get triggered? No, it doesn't, which exactly is my problem. Frank

There's a bug in application.inc, line 816. OnShowHint only executes if there are hint handlers registered:

(...)
  i:=FApplicationHandlers[ahtShowHint].Count;
  if CanShow and (i>0) then begin
    if Assigned(FOnShowHint) then
      FOnShowHint(HintInfo.HintStr, CanShow, HintInfo);
(...)

Regards,
Fl?vio

Reply by email

Mattias Gaertner
to Flávio Etrusco
Show quoted text 34 lines
On Sun, Mar 30, 2014 at 12:21 PM, Frank Poretzky wrote: > Hi Graeme, > > on Sun, 30 Mar 2014 10:09:31 +0100, you wrote: > >>On 2014-03-30 04:45, Frank Poretzky wrote: >>> >>> | procedure TFormTest.DoAppOnShowHint( var HintStr: String; >>> | var CanShow: Boolean; >>> | var HintInfo: THintInfo); >>> | begin >>> | CanShow := true; >>> | HintStr := HintStr + ' - Modified'; >>> | end; >> >> >>Does the DoAppOnShowHint() actually execute? If you set a breakpoint in >>that method, does it get triggered? > > No, it doesn't, which exactly is my problem. > > Frank > There's a bug in application.inc, line 816. OnShowHint only executes if there are hint handlers registered: (...) i:=FApplicationHandlers[ahtShowHint].Count; if CanShow and (i>0) then begin if Assigned(FOnShowHint) then FOnShowHint(HintInfo.HintStr, CanShow, HintInfo); (...)

Thanks for the hint.

Fixed.

Mattias

Reply by email

Frank Poretzky
to Flávio Etrusco: On Sun, Mar 30, 2014 at 12:21 PM, Frank Poretzky There's a bug in application.inc, line…

Hi Fl?vio,

you wrote 9 lines
There's a bug in application.inc, line 816. OnShowHint only executes if there are hint handlers registered: (...) i:=FApplicationHandlers[ahtShowHint].Count; if CanShow and (i>0) then begin if Assigned(FOnShowHint) then FOnShowHint(HintInfo.HintStr, CanShow, HintInfo); (...)

I see. After changing it to

|   i:=FApplicationHandlers[ahtShowHint].Count;
|   if CanShow then begin
|     if Assigned(FOnShowHint) then
|       FOnShowHint(HintInfo.HintStr, CanShow, HintInfo);
|     if i>0 then
|       while FApplicationHandlers[ahtShowHint].NextDownIndex(i) do
|         TShowHintEvent(FApplicationHandlers[ahtShowHint][i])(HintInfo.HintStr, CanShow, HintInfo);
|   end;

I get the expected results.

Many thanks to you and Graeme. Great service!

Frank

Reply by email