13,825
社区成员
发帖
与我相关
我的任务
分享
Application->HintPause = 100;
TToolInfo ToolInfo;
void TForm1::AddToolTip(HWND hWnd, int IconType,char *Text,char *Title, TColor BackColor,TColor TextColor)
{
HWND hTooltip;
char buffer[256];
TRect Rect;
hTooltip =CreateWindowEx(0/*WS_EX_TOPMOST*/,
TOOLTIPS_CLASS,
0,
TTS_BALLOON,/*|TTS_ALWAYSTIP|TTS_NOPREFIX*/
0,
0,
0,
0,
Form1->Handle,
0,
0,
NULL);
if (hTooltip != 0 )
{
SetWindowPos(hTooltip, 0/*HWND_TOPMOST*/, 0, 0, 0, 0, /*SWP_NOMOVE|SWP_NOSIZE|*/SWP_NOACTIVATE);
ToolInfo.cbSize = sizeof(TToolInfo);
ToolInfo.uFlags = TTF_SUBCLASS;//|TTF_TRANSPARENT;
ToolInfo.hinst = NULL;
//ToolInfo.uId=
}
if( hWnd != 0 && ::GetClientRect(hWnd, &Rect) )
{
ToolInfo.hwnd=hWnd;
ToolInfo.rect=Rect;
ToolInfo.lpszText=Text;
SendMessage(hTooltip, TTM_ADDTOOL, 0, int(&ToolInfo));
memset(buffer, 0, sizeof(buffer));
lstrcpy(buffer,Title);
if(IconType>3 || IconType<0) IconType = 0;
if (BackColor!=0 ) SendMessage(hTooltip, TTM_SETTIPBKCOLOR, BackColor, 0);
if (TextColor!=0 ) SendMessage(hTooltip, TTM_SETTIPTEXTCOLOR, TextColor, 0);
if (Title!=0) SendMessage(hTooltip, TTM_SETTITLE, IconType, int(&buffer));
}
}
void __fastcall TForm1::btn1Click(TObject *Sender)
{
AddToolTip(edt1->Handle,1, "fdf", "ee",clRed,clBlue);
}