Page 1 of 1

ShowHint

Posted: Wed Mar 07, 2018 8:04 pm
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?

Re: ShowHint

Posted: Thu Mar 08, 2018 10:21 am
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.

Re: ShowHint

Posted: Thu Mar 08, 2018 10:34 am
by petko
Thank you very much! I'd give it a try.