|
EControl Ltd. VCL libraries and software support forum
|
View previous topic :: View next topic |
Author |
Message |
Viola
Joined: 03 Dec 2008 Posts: 4 Location: Raleigh, NC, USA
|
Posted: Thu Dec 04, 2008 9:02 pm Post subject: Problems implementing token hints in SyntaxMemo |
|
|
Hi
I've implemented token hints in SyntaxMemo by handling the OnGetTokenHint event. So far, so good.
However, I am having a couple of problems and was hoping that someone would be able to offer some advice.
The problems are:
1) The hints only work if the SyntaxMemo has focus. I would like to be able to have the token hints show when SyntaxMemo is moused over, even if it doesn't have focus.
2) If I set the HintProps.Formatted flag to "True", this shows the hints with the same formatting as the SyntaxMemo. If I set the flag to "False", I can change the font/colours to whatever I like via HintProps's other properties, but the hint-box doesn't adjust its size to my chosen font (i.e. if I choose a small font, the hint text shows in the top-left corner of the hint-box and the rest is empty; and if I choose a big font, only the top-left corner of the text shows).
Please can you advise me/point me in the right direction so that I can solve these problems?
Thanks
Viola |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Thu Dec 04, 2008 10:15 pm Post subject: |
|
|
Hello,
1. Yes, I agree. Hints should be available even when editor does not have focus.
Fix (ecSyntMemo.pas):
Code: | procedure TCustomSyntaxMemo.HintTimer(Sender: TObject);
var p, cp, pHint, pn, sp, ep: TPoint;
i, j, Y1, Y2, TokenIdx, H, Y: integer;
Text: string;
R: TRect;
gi: TCustomGutterObject;
b: Boolean;
te: TecTextMargin;
Ln: TLineInfo;
begin
UpdateCaretPos;
if (FHintTimer.Tag = 1) {or (not Focused)} then
begin
ResetHint;
Exit;
end;
.........
|
2. This is a bug.
Fix (ecSyntMemo.pas):
Code: | function TSyntHintWindow.CalcHintRect(MaxWidth: Integer;
const AHint: String; AData: ecPointer): TRect;
.........
Result.Bottom := FComplRender.Height;
end else
begin
Canvas.Font := Self.Font; // <== Fix
DrawText(Canvas.Handle, ecPChar(AHint), -1, Result, DT_CALCRECT or DT_LEFT or DT_EXPANDTABS or
DT_WORDBREAK or DT_NOPREFIX or DrawTextBiDiModeFlagsReadingOnly);
end;
Inc(Result.Right, SideOffset);
end;
end; |
Michael. |
|
Back to top |
|
|
Viola
Joined: 03 Dec 2008 Posts: 4 Location: Raleigh, NC, USA
|
Posted: Fri Dec 05, 2008 12:07 am Post subject: |
|
|
Both fixes worked. Thanks. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|