1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
String g_GlobalHint = "" ;
//---------------------------------------------------------------------------
void __fastcall THintWindow::NCPaint(HDC DC)
{
//
}
//---------------------------------------------------------------------------
TRect __fastcall TMyHintWindow::CalcHintRect(int MaxWidth, AnsiString AHint, void * AData)
{
Canvas->Font->Size = 9;
Canvas->Font->Color = clBlue;
Canvas->Font->Name = "Arial";
Canvas->Font->Style = TFontStyles() << fsBold;
TSize size ;
GetTextExtentPoint(Canvas->Handle,g_GlobalHint.c_str(),g_GlobalHint.Length(),&size);
TRect rect = THintWindow::CalcHintRect(MaxWidth, AHint, AData);
rect.Right = 10 + rect.Left + size.cx + 10 ;
return rect;
}
//---------------------------------------------------------------------------
void __fastcall TMyHintWindow::Paint(void)
{
TRect arect = this->GetClientRect();
HRGN hRegion = CreateRoundRectRgn(arect.left, arect.top, arect.right, arect.bottom, 20, 20);
SetWindowRgn(this->Handle, hRegion, true);
HICON aicon = LoadIcon(NULL, IDI_ASTERISK);
this->Canvas->Brush->Color = clInfoBk;
this->Canvas->FillRect(arect);
this->Canvas->Ellipse(arect);
TRect brect = arect;
brect.Right -= 3;
brect.Bottom -= 2;
RoundRect(this->Canvas->Handle,brect.Left,brect.Top,brect.Right,brect.Bottom,20,20);
this->Canvas->Font->Size = 9;
this->Canvas->Font->Color = clBlue;
this->Canvas->Font->Name = "Ms Sans Serif";
this->Canvas->Font->Style = TFontStyles() << fsBold;
SelectObject(Canvas->Handle, Canvas->Font->Handle);
SetBkMode(Canvas->Handle, TRANSPARENT);
TRect crect = arect;
crect.Left += 60;
crect.Top += 5;
DrawIcon( this->Canvas->Handle, 5, 5, aicon );
DrawText( this->Canvas->Handle,g_GlobalHint.c_str(),g_GlobalHint.Length(), &crect, DT_LEFT | DT_VCENTER);
String S = AnsiString("\n");
S = S + AnsiString("\n");
S = S + AnsiString(" : Fait\n");
S = S + AnsiString(" : Fait\n");
crect.Left += 180;
DrawText( this->Canvas->Handle,S.c_str(),S.Length(), &crect, DT_LEFT | DT_VCENTER);
crect.Top = 5;
crect.Left = brect.Right - GetSystemMetrics(SM_CXSIZE) - 5;
crect.Right = crect.Left + GetSystemMetrics(SM_CXSIZE);
crect.Bottom = crect.Top + GetSystemMetrics(SM_CYSIZE);
DrawFrameControl( this->Canvas->Handle, &crect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
}
//-------------------------------------------------------------------------
void __fastcall TForm2::MyOnShowHint(AnsiString &HintStr, bool &CanShow, THintInfo &HintInfo)
{
AnsiString csName = HintInfo.HintControl->ClassName() ;
g_GlobalHint = "" ;
if (csName == "TMemo") { g_GlobalHint = (String)((TMemo*)HintInfo.HintControl)->Hint ; }
if (csName == "TLabel") { g_GlobalHint = (String)((TLabel*)HintInfo.HintControl)->Hint ; }
if (csName == "TCheckBox") { g_GlobalHint = (String)((TCheckBox*)HintInfo.HintControl)->Hint ; }
if (!g_GlobalHint.IsEmpty())
{
HintInfo.HintWindowClass = __classid( TMyHintWindow );
HintInfo.HideTimeout = 10000;
CanShow = true;
}
else
{
HintInfo.HintWindowClass = __classid( THintWindow );
CanShow = true ;
}
}
//---------------------------------------------------------------------- |
Partager