Recent

Author Topic: Setting font in THintWindow  (Read 6073 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Setting font in THintWindow
« on: February 26, 2015, 08:06:23 am »
Hello,

i derived a class from THintWindow and changed the Canvas.Font in it's Constructor. The Constructor gets called but the apperance didn't change. Even Changing the color makes no difference. What am i doing wrong here?

Code: [Select]
  TsusHintWindow = class(THintWindow)
    constructor Create(AOwner: TComponent); override;
  end;

Code: [Select]
constructor TsusHintWindow.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  with Canvas.Font do begin
    Name := 'Courier New';
    Size := 10;
  end;
end;

Code: [Select]
procedure TEditorFile.ShowHint(Sender: TObject; HintInfo: PHintInfo);
begin
  HintInfo^.Hint := '----|----1----|----2----|----3'+chr(10)+'abcdefghijklmnopqrsyvw';
  HintInfo^.HintWindowClass := TsusHintWindow;
end;
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Setting font in THintWindow
« Reply #1 on: February 26, 2015, 12:26:59 pm »
What is the declaration for TEditorFile?

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Setting font in THintWindow
« Reply #2 on: February 26, 2015, 09:30:27 pm »
TSynEdit.OnShowHint is set to TEditorFile.ShowHint. So this function is
an event funtion and the type TEditorFile doesn't have any influence.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Setting font in THintWindow
« Reply #3 on: February 27, 2015, 12:59:35 am »
It seems you have to change the hintwindow Color from its default of clInfoBk, otherwise painting is done via themes and the font settings are ignored. This works for me (Win 7).
Code: [Select]
constructor TsusHintWindow.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Font.Name:='Courier New';
  Font.Size:=12;
end;

procedure TForm1.SynEdit1ShowHint(Sender: TObject; HintInfo: PHintInfo);
begin
  HintInfo^.HintWindowClass:=TsusHintWindow;
  HintInfo^.HintColor:=clMoneyGreen;
  HintInfo^.HideTimeout:=5000;
  HintInfo^.HintStr:='----|----1----|----2----|----3'+chr(10)+'abcdefghijklmnopqrsyvw';
end;

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Setting font in THintWindow
« Reply #4 on: February 27, 2015, 01:17:14 am »
Version of Lazarus?
Is this a regression?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Setting font in THintWindow
« Reply #5 on: February 27, 2015, 08:07:37 am »
howardpc,

this works! Thanks.
I've seen the themes routines but i've changed the wrong color, so no effect there!
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Setting font in THintWindow
« Reply #6 on: February 27, 2015, 09:29:17 am »
Version of Lazarus?
Is this a regression?
No, it's clearly a designed feature. The trunk version of UseThemes (a boolean called in THintWindow.Paint) is
Code: [Select]
function THintWindow.UseThemes: Boolean;
begin
  Result := (Color = clInfoBk) or (Color = clDefault);
end; 
It has been this way for ages, I presume since it was first written.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Setting font in THintWindow
« Reply #7 on: February 27, 2015, 10:06:34 am »
Code: [Select]
function THintWindow.UseThemes: Boolean;
begin
  Result := (Color = clInfoBk) or (Color = clDefault);
end; 

Ok, right. It is not very intuitive but I guess it is needed for Delphi compatibility.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018