Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

ShowHint

Post Reply
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

ShowHint

Post by petko »

It seems that it is not possible to show hint over the TChromiumWindow (setting the Hint property does nothing). Is there some workaround?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ShowHint

Post by salvadordf »

CEF creates a child component to show the browser contents when an app calls CreateBrowser. The parent of that component is TCEFWindowParent or TChromiumWindow and it hides the parent completely.

Perhaps you can show a hint with Application.ActivateHint like this :
https://stackoverflow.com/questions/239 ... ctive-form

This is an alternative way to show hints :
https://www.experts-exchange.com/questi ... focus.html

Code: Select all

function RevealHint (Control: TControl): THintWindow; 
{----------------------------------------------------------------} 
{ Pops up Hint window for the specified Control, and returns a   } 
{ reference to the hint object so it may subsequently be removed } 
{ with RemoveHint (see below).                                   } 
{----------------------------------------------------------------} 
 var 
   ShortHint: string; 
   AShortHint: array[0..255] of Char; 
   HintPos: TPoint; 
   HintBox: TRect; 
 begin 
   { Create the window: } 
   Result := THintWindow.Create(Control); 

   { Get first half of hint up to '|': } 
   ShortHint := GetShortHint(Control.Hint); 

   { Calculate Hint Window position & size: } 
   HintPos := Control.ClientOrigin; 
   Inc(HintPos.Y, Control.Height + 6);    <<<< See note below 
   HintBox := Bounds(0, 0, Screen.Width, 0); 
   DrawText(Result.Canvas.Handle, 
       StrPCopy(AShortHint, ShortHint), -1, HintBox, 
       DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX); 
   OffsetRect(HintBox, HintPos.X, HintPos.Y); 
   Inc(HintBox.Right, 6); 
   Inc(HintBox.Bottom, 2); 

   { Now show the window: } 
   Result.ActivateHint(HintBox, ShortHint); 
 end; {RevealHint} 

 procedure RemoveHint (var Hint: THintWindow); 
{----------------------------------------------------------------} 
{ Releases the window handle of a Hint previously popped up with } 
{ RevealHint.                                                    } 
{----------------------------------------------------------------} 
 begin 
   Hint.ReleaseHandle; 
   Hint.Free; 
   Hint := nil; 
 end; {RemoveHint} 
 
The line marked <<<< above is the one that positions the hint 
window below the control.  This could obviously be altered if 
you want a different position for some reason.  
PS : I'll add "ShowHint" to the TCEFWindowParent's published properties in the next CEF4Delphi version.
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: ShowHint

Post by petko »

Thank you very much! I'd give it a try.
Post Reply