Board index » delphi » Turning off pop-up hints

Turning off pop-up hints

I use a lot of pop-up hints in my program since my program will generally be
used by newbies. For a user who knows what he's doing, hwever, these hints
can become annoying. I'd like to have a menu option to turn off the hints,
and to do so by cycling through all the components on the form and setting
the showhints property to false. However, when I use the following code, it
generates an error:

for i:=0 to componentcount-1 do
  components[i].showhint:=false;

can anyone tell me what I'm doing wrong, and what I need to do to fix it?
I'd hate to have to manually turn off the hints one by one, eg:

button1.showhint:=false;
button2.showhint:=false;
label1.showhint:=false;

there has to be a better way, yes?

 

Re:Turning off pop-up hints


If I recall correctly, there's an Application.ShowHint that
can be set to True or False.  See if that helps.

Quote
Barry Cacella (barrycace...@home.com) wrote:

: I use a lot of pop-up hints in my program since my program will generally be
: used by newbies. For a user who knows what he's doing, hwever, these hints
: can become annoying. I'd like to have a menu option to turn off the hints,
: and to do so by cycling through all the components on the form and setting
: the showhints property to false. However, when I use the following code, it
: generates an error:

: for i:=0 to componentcount-1 do
:   components[i].showhint:=false;

: can anyone tell me what I'm doing wrong, and what I need to do to fix it?
: I'd hate to have to manually turn off the hints one by one, eg:

: button1.showhint:=false;
: button2.showhint:=false;
: label1.showhint:=false;

: there has to be a better way, yes?
--
Rick Carter
carte...@email.uc.edu

Re:Turning off pop-up hints


Quote
Barry Cacella <barrycace...@home.com> wrote in message

news:eLHA3.16444$9K.11552@news.rdc1.nj.home.com...

Quote
> I use a lot of pop-up hints in my program since my program will generally
be
> used by newbies. For a user who knows what he's doing, hwever, these hints
> can become annoying. I'd like to have a menu option to turn off the hints,
> and to do so by cycling through all the components on the form and setting
> the showhints property to false. However, when I use the following code,
it
> generates an error:

> for i:=0 to componentcount-1 do
>   components[i].showhint:=false;

Well, a someone else has pointed out, there is an Application.ShowHint
property that toggles hints on and off for all controls. But to answer the
question about why your code doesn't work; it's because when you access the
Components array you get back a TComponent object, and TComponent doesn't
have a ShowHint property. Only certain descendants of it do.

The way around this is to check the property info for each component to see
if it has a ShowHint property, and change it if it has. Here's how you would
do that:

uses TypInfo;

procedure SetShowHintProperty(AComponent: TComponent; Value: Boolean);
var
  PInfo: PPropInfo;
begin
  PInfo := GetPropInfo(AComponent.ClassInfo, 'ShowHint' );
  if Assigned(PInfo) and (PInfo^.Proptype^.Kind = tkEnumeration) then
    SetOrdProp(AComponent, PInfo, Ord(Value));
end;

Call the above method like this...
var
  i: integer;
begin
  for i := 0 to ComponentCount - 1 do
    SetShowHintProperty(Components[i], False);
end;

--
Stephen Brown

Re:Turning off pop-up hints


yes, i tried that first. it doesn't work.

Re:Turning off pop-up hints


Quote
>yes, i tried that first. it doesn't work.

Why not? It works when I tried it. Are you using some kind of a third party
hint facelift?

Aapo Laitinen
aa...@mbnet.fi

Other Threads