Mega Search
23.2 Million


Sign Up

Make a donation  
How to turn off Bold text in the application hint box?  
News Group: embarcadero.public.cppbuilder.language.cpp

I am using CB XE4 Pro with VCL 32bit platform.

I am using the Windows Application Hint box to follow the cursor around as it moves over the surface of the TPaintBox. Sometimes the text in the hint box is bold which I do not want. I want to add a command just before ActivateHint to turn off the bold but I can not find any such command. How can I control the text in the hint box so it is never bold. 

void __fastcall TPCForm::PaintBox1_PCMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
  PaintBox1_PC->Hint = MyHintMsg;

  TPoint point;

  Application->ActivateHint( ClientToScreen( Point(X +10,Y - 10) ));
}

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 22-Dec-2014, at 7:25 AM EST
From: Patrick Mikula
 
Re: How to turn off Bold text in the application hint box?  
News Group: embarcadero.public.cppbuilder.language.cpp
Patrick wrote:

> I am using the Windows Application Hint box to follow the cursor around
> as it moves over the surface of the TPaintBox. Sometimes the text in the
> hint box is bold which I do not want. I want to add a command just before
> ActivateHint to turn off the bold but I can not find any such command.

That is a side effect from misusing ActivateHint().  The *correct* way to 
update the hint is to either:

1. use the TApplication(Events)::OnShowHint event:

{code}
void __fastcall TPCForm::ApplicationEvents1ShowHint(String &HintStr, bool 
&CanShow, THintInfo &HintInfo)
{
    if (HintInfo.HintControl == PaintBox1_PC)
    {
        HintInfo.CursorPos = Point(X+10, Y-10);
        HintInfo.CursorRect = Rect(HintInfo.CursorPos.X, HintInfo.CursorPos.Y, 
HintInfo.CursorPos.X+1, HintInfo.CursorPos.Y+1);
        HintInfo.HintStr = MyHintMsg;
    }
}
{code}


2. subclass the TPaintBox and handle the CM_HINTSHOW message:

{code}
private:
    TWndMethod OldWndProc;

__fastcall TPCForm::TPCForm(TComponent *Owner)
    : TForm(Owner)
{
    OldWndProc = PaintBox1_PC->WindowProc;
    PaintBox1_PC->WindowProc = &PaintBoxWndProc;
}

__fastcall TPCForm::~TPCForm()
{
    PaintBox1_PC->WindowProc = OldWndProc;
}

void __fastcall TPCForm::PaintBoxWndProc(TMessage &Message)
{
    OldWndProc(Message);

    if (Message.Msg == CM_HINTSHOW)
    {
        PHintInfo HintInfo = reinterpret_cast(Message.LParam);
        HintInfo->CursorPos = Point(X+10, Y-10);

        HintInfo->CursorRect = Rect(HintInfo->CursorPos.X, HintInfo->CursorPos.Y, 
HintInfo->CursorPos.X+1, HintInfo->CursorPos.Y+1);
        // alternatively:
        /*
        HintInfo->CursorRect.TopLeft = HintInfo->CursorPos;
        HintInfo->CursorRect.BottomRight = Point(HintInfo->CursorPos.X+1, 
HintInfo->CursorPos.Y+1);
        */
        /*
        HintInfo->CursorRect.Location = HintInfo->CursorPos;
        HintInfo->CursorRect.Size = Size(1, 1);
        */

        HintInfo->HintStr = MyHintMsg;
    }
}
{code}

--
Remy Lebeau (TeamB)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 22-Dec-2014, at 9:39 AM EST
From: Remy Lebeau (TeamB)