13,873
社区成员
发帖
与我相关
我的任务
分享
void TForm2::AddToolTip(HWND hWnd ,int IconType,char *Text,char *Title ,
TColor BackColor,TColor TextColor,int x,int y)
{
TToolInfo ToolInfo;
char buffer[256];
TRect Rect;
TPoint lpPoint; // screen coordinates
lpPoint.x = x;
lpPoint.y = y;
::ClientToScreen(hWnd,&lpPoint);
if(hTooltip != 0)
{
SetWindowPos(hTooltip, 0/*HWND_TOPMOST*/, lpPoint.x, lpPoint.y, 0, 0,/*SWP_NOMOVE|SWP_NOSIZE|*/SWP_NOACTIVATE|SWP_SHOWWINDOW);
ToolInfo.cbSize = sizeof(TToolInfo);
ToolInfo.uFlags = TTF_SUBCLASS;//|TTF_TRANSPARENT;
ToolInfo.hinst = NULL;
}
else
{
hTooltip = 0;
}
//Rect = GetClientRect();
::GetClientRect(hWnd, &Rect);
if(hWnd != 0 )
{
ToolInfo.hwnd=hWnd;
ToolInfo.rect=Rect;
ToolInfo.lpszText=Text;
SendMessage(hTooltip,TTM_ADDTOOL,0,int(&ToolInfo));
memset(buffer,sizeof(buffer),'0');
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));
}
// OldWindowProc = (WNDPROC)::GetWindowLong(hTooltip, GWL_WNDPROC);
// ::SetWindowLong(hTooltip, GWL_WNDPROC, (LONG)NewWindowProc);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormMouseMove(TObject *Sender, TShiftState Shift, int X,
int Y)
{
String strPoint = "";
TVarRec args[2] = {X,Y};
strPoint = Format("%d,%d",args,2);
AddToolTip(this->Handle, 1,strPoint.c_str() , Application->Title.c_str(),(TColor)0,(TColor)0,X,Y);
}