Mega Code Archive

 
Categories / Delphi / Ide Indy
 

Activate one hint for the source code

Title: Activate one hint for the source code Question: I would like that Hint it Edit appeared when the user is typing some thing in it and not only when mouse is passed by top. He is possible to make this? Answer: You it will have that to make manually this. You it will have that to use canvas to draw hint. create one public variable to control the state of hint: var Myhint: THintWindow; Now put in the form, this function to activate the hint: function TForm1.RevealHint (Control: TControl): THintWindow; var ShortHint: string; AShortHint: array[0..255] of Char; HintPos: TPoint; HintBox: TRect; begin Result := THintWindow.Create(Control); ShortHint := GetShortHint(Control.Hint); HintPos := Control.ClientOrigin; Inc(HintPos.Y, Control.Height + 6); 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); Result.ActivateHint(HintBox, ShortHint); end; and put the your this procedure to deactivate the Hint: procedure TForm1.RemoveHint (var Hint: THintWindow); begin Hint.ReleaseHandle; Hint.Free; Hint := nil; end; to activate hint: Myhint :=RevealHint(edit1); // change the name edit1 for the name of the component that you wants that he appears hint To Deactivate Hint: RemoveHint(Myhint)