Link to home
Start Free TrialLog in
Avatar of 966
966

asked on

hint

can someone give me some working examples of how the hint works please delphi 6,7.
Avatar of cebasso
cebasso
Flag of United States of America image

i really don't know exactly what are you talking about...
anyway... for a normal hint, you just need to set the Hint property on the component with what you wanna show and the ShowHint property to True example
Hint := 'This is a hint';
ShowHint := True;
you can set at the Object Inspector
for the component show his parent Hint, set the property ParentShowHInt to True
i hope its what you are talking about hahahaha
Avatar of Emmanuel PASQUIER
for each form, panel, control, etc... where you want a Hint buble to show up when leaving the mouse over it a few seconds, you have to do 2 things :
set the Hint property with the text you want
set the ShowHint property to true.

for the ShowHint property, it's possible to only set the ShowHint of the form, and by default all components you place on it have the ParentShowHint set to true, which means that their own ShowHint will take the value of the parent (ie the form). Much like the Font & ParentFont property
Avatar of 966
966

ASKER

Thanks , can i change the colour and font of the hint box ?
Avatar of 966

ASKER

If i use flat hint, how would i add code to show a hint instead.

procedure TForm1.FlatHint1ShowHint(var HintStr: String;
  var CanShow: Boolean; var HintInfo: THintInfo);
begin

end;
Avatar of 966

ASKER

when i set it up as follows, ias soon as i "hover" over label 1, it displays the hint using my flat component. Im aware youdont have the component, but there are no options on this, the component just dispays a cool arror next to it. However, when i gover off from the label and back onto it again, it gives an error

" flathint1 is already used"

what code can i add to fix this, ive tried to free it, but nothing.

procedure TForm1.FlatHint1ShowHint(var HintStr: String;
  var CanShow: Boolean; var HintInfo: THintInfo);
begin
flathint1.Create(label1);
end;
Avatar of 966

ASKER

yes after i cancel the error box it works fine .. :(
To change the hint color, you can use SetSysColors (and GetSysColor to get the current values) with COLOR_INFOBK

http://www.delphi-zone.com/2010/02/how-to-get-set-system-colors/

MSDN Ref :
http://msdn.microsoft.com/en-us/library/ms724940%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms724371%28VS.85%29.aspx

procedure SetupHintColor(C:TColor);
Const
 Element: TColor = COLOR_INFOBK;
begin
 SetSysColors(1, Element, C);
end;

Open in new window

Avatar of 966

ASKER

doesnt matter about flat hint, stay with the standard one i think. So again, how would i change background from grey ?
Avatar of 966

ASKER

ah cool, i just typed that withought rfreshing, ill check it out now
Avatar of 966

ASKER

So if i wanted background colour blue and text colour red, how would the code be?
ok, what I told you before would change the Hint back Color for all application for this windows session.

here is how with Delphi you can change only your application Hint properties :
Application.hintpause:=20000; //set how long hint showed Application.hinthidepause:=0; //delay time before hint is hidden
Application.hintcolor:=clBlue; //hint back color Screen.hintfont.name:='times new roman'; //hint font type Screen.hintfont.color:=clRed; //hint font color 
Screen.hintfont.style:=[fsbold,fsitalic]; //hint style

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 966

ASKER

great!
Avatar of 966

ASKER

procedure SetupHintColor(C:TColor);
begin
Application.hintpause:=20000; //set how long hint showed
Application.hinthidepause:=0; //delay time before hint is hidden
Application.hintcolor:=clBlue; //hint back color
Screen.hintfont.name:='times new roman'; //hint font type
Screen.hintfont.color:=clRed; //hint font color
Screen.hintfont.style:=[fsbold,fsitalic]; //hint style
end;

? like this?
Avatar of 966

ASKER

not sure how to set it out mate, the above i posted is wrong i just relised.
:-)))  ???

Anyway,if you can get TMS components it has a nice message box that works
perfect for hints and is highly configurable....
You don't use the C parameter of your function. I only provided all the things you could change about your Hint visual aspect and behaviour. just add these lines (not even all, only the one you need to change) and call this procedure in your application main form creation

procedure SetupHintColor;
begin
 Application.hintpause:=20000; //set how long hint showed
 Application.hinthidepause:=0; //delay time before hint is hidden
 Application.hintcolor:=clBlue; //hint back color
 Screen.hintfont.name:='times new roman'; //hint font type
 Screen.hintfont.color:=clRed; //hint font color
 Screen.hintfont.style:=[fsbold,fsitalic]; //hint style
end;

Open in new window