- This topic has 7 replies, 3 voices, and was last updated 12 years, 2 months ago by Support.
-
AuthorPosts
-
August 11, 2012 at 1:02 am #35303IPStevenParticipant
Is there a way to offset the Hint window position?
Part of hint window is under the cursor making it hard to read.
I would like to be able to move the hint window just a slight bit to the right.
Also
Is it possible that you could add properties to HintManager (x position offset/y position offset) to the next version?
thanks
August 13, 2012 at 5:43 am #48744HamiltonParticipantHi IPSteven,
I haven't used TsAlphaHints but the generic code may allow you to do what you're after:
http://docwiki.embarcadero.com/CodeSamples/en/OnShowHint_(Delphi)
Regards,
Hamilton.
August 13, 2012 at 5:45 am #48745HamiltonParticipantThat link doesn't appear to be working so hopefully Embarcadero don't mind me posting their sample code:
Code:procedure TForm1.DoShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo);
begin
if HintInfo.HintControl = SpeedButton3 then
begin
with HintInfo do
begin
HintColor := clAqua;{ Changes only for this hint. }
HintMaxWidth := 120;{Hint text word wraps if width is greater than 120. }
Inc(HintPos.X, SpeedButton3.Width); { Move hint to the right edge. }
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowHint := True;
Application.OnShowHint := DoShowHint;
end;August 13, 2012 at 6:32 am #48746IPStevenParticipantHamilton,
Thanks for the reply.
That works if you're not using the AlphaSkins HintManager.
When using the AlphaSkins HintManager
TsCustomHintWindow.ActivateHintwhich is called after the OnShowHint event appears to ignore the HintPos position information entirely and calculate its own coordinates.
I'm hoping there is a way to do this (create the offsets) that doesn't involve hacking the AlphaSkins code because that creates maintenance issues later on.
August 14, 2012 at 7:01 am #48759HamiltonParticipantHi IPSteven,
I traced through the code and can see that the TsAlphaHints component has it's own OnShowHint method; if you put the code to manipulate the hint position (and color etc) in that event handler rather than the Application.OnShowHint method then everything will work as you expect. I tested setting the absolute and relative position and both worked as you would expect.
Aside: Setting the color in the OnShowHint method did not work but that is probably part of the design, I didn't use the SkinManager to see if this could be controlled as it is outside the scope of the OP.
Anyway good luck!
Regards,
Hamilton
August 14, 2012 at 4:58 pm #48764IPStevenParticipantHamilton
Thanks for pointing out that the TsAlphaHints component has it's own OnShowHint method.
I was calling my on function by doing:
Application.OnShowHint := MyShowHint;
I used my function MyShowHint() to manually control the wrapping of my hint text.
I moved my code into the HintManger.ShowHint() and the default position of the hint window changed! Its actually usable.
I tried again to offset the hint window's X position – and it wasn't working.
In tracing out the code I found that is TsHintManager.OnShowHintApp is being called after ShowHint()
Code:procedure TsHintManager.OnShowHintApp(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
begin
FHintPos := HintInfo.HintPos;
if Assigned(FOnShowHint) then FOnShowHint(HintStr, CanShow, HintInfo, HintFrame) else inherited;
if (FHintPos.x HintInfo.HintPos.x) and (FHintPos.y HintInfo.HintPos.y) then FHintPos := HintInfo.HintPos else begin
end;
end;the code shows that unless I change both the X & Y coordinates that the changes are discarded!
Testing verified that the HintPos can be changed as long as I change both X & Y coordinates by at least +/- 1.
Thanks for your help in unraveling this, much appreciated.
August 17, 2012 at 6:10 am #48780HamiltonParticipantMy pleasure.
Another workaround is to set the HintPos values specifically; in sAlphaHints1ShowHint instead of manipulating HintInfo.HintPos if you just set HintPos specifically that will work too, and you won't have to change both the x and y coords if you do this (but it may have other side effects I haven't considered so perhaps your original solution is best after all). Anyway just throwing it out there!
Serge: can you please fix the bug that IPSteven pointed out; the line of code should be:
Code:if (FHintPos.x <> HintInfo.HintPos.x) or (FHintPos.y <> HintInfo.HintPos.y) then FHintPos := HintInfo.HintPos else beginRegards,
Hamilton
August 24, 2012 at 8:02 am #48829SupportKeymasterHello!
Yes, this code will be changed, thanks 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.