Board index » cppbuilder » Change Font in Hint

Change Font in Hint

Hi, I need to change the Font in Hint, this code is working well in
Delphi , but it is not  working in C++ Builder. Is dear any thing I am
doing wrong.

Code in Delphi :

implementation
{$R *.DFM}
procedure TForm1.MyShowHint(var HintStr: string;
                            var CanShow: Boolean;
                            var HintInfo: THintInfo);
var
  i : integer;
begin
  for i := 0 to Application.ComponentCount - 1 do
    if Application.Components[i] is THintWindow then
      with THintWindow(Application.Components[i]).Canvas do begin
        Font.Name   := 'Tahoma';
        Font.Size   := 8;
        HintInfo.HintColor := clYellow;
      end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
     Application.OnShowHint := MyShowHint;
end;

C++ Builder 4.0:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Application->ShowHint = true;
  Application->OnShowHint = DoShowHint;

Quote
}

//---------------------------------------------------------------------------

void __fastcall TForm1::DoShowHint(System::AnsiString &HintStr, bool
&CanShow, THintInfo &HintInfo)
{
  int iCont;

  for (iCont = 0 ; iCont <= Application->ComponentCount - 1; iCont ++ )
  {

      THintWindow(Application->Components[iCont]).Canvas->Font->Name =
"Tahoma";
      THintWindow(Application->Components[iCont]).Canvas->Font->Size =
8;
      HintInfo.HintColor = clYellow;
  }

Quote
}

Thanks in advance !!!
 

Re:Change Font in Hint


Hi Ricardo,

Quote
> Hi, I need to change the Font in Hint, this code is working well in Delphi ,
> but it is not working in C++ Builder. Is dear any thing I am doing wrong.

You need to correct the conversion...

    int count = Application->ComponentCount;
    for (int index = 0; index < count; ++index)
    {
        THintWindow *HintWindow =
            dynamic_cast<THintWindow *>(Application->Components[index]);
        if (HintWindow)
        {
            HintWindow->Canvas->Font->Name = "Tahoma";
            HintWindow->Canvas->Font->Size = 8;
            HintInfo.HintColor = clYellow;
        }
    }

Good luck!

--
Damon Chandler
http://bcbcaq.freeservers.com

Other Threads