靴
靴子
Unregistered / Unconfirmed
GUEST, unregistred user!
unit SherryHint;
interface
uses
Windows, Messages, Classes, Controls, Forms, CommCtrl;
type
THintWin=class(THintWindow)
private
FLastActive: Tpoint;
public
titlestr : string;
procedure ActivateHint(Rect:TRect;Const AHint:string);override;
end;
implementation
procedure AddTipTool(hWnd: DWORD; IconType: Integer; Title, Text: PChar);
const
TTS_BALLOON =$0040;
TTM_SETTITLE=WM_USER + 32;
var
hWndTip: DWORD;
ToolInfo: TToolInfo;
begin
hWndTip:=CreateWindow(TOOLTIPS_CLASS, nil,
WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
0, 0, 0, 0, hWnd, 0, HInstance, nil);
if (hWndTip<>0) then
begin
ToolInfo.cbSize:=SizeOf(ToolInfo);
ToolInfo.uFlags:=TTF_IDISHWND or TTF_SUBCLASS or TTF_TRANSPARENT;
ToolInfo.uId:=hWnd;
ToolInfo.lpszText:=Text;
SendMessage(hWndTip,TTM_ADDTOOL,1,Integer(@ToolInfo));
SendMessage(hWndTip,TTM_SETTITLE,IconType,Integer(Title));
end;
InitCommonControls();
end;
procedure THintWin.ActivateHint(Rect:TRect;const AHint:string);
begin
if (FLastActive.X<>Mouse.CursorPos.X) or (FLastActive.y<>Mouse.CursorPos.y) then
AddTipTool(WindowFromPoint(Mouse.CursorPos),1,PChar(titlestr), PChar(AHint));//Application.Hint));
FLastActive:=Mouse.CursorPos;
end;
initialization
Application.HintPause:=0;
Application.ShowHint:=False;
HintWindowClass:=THintWin;
Application.ShowHint:=True;
end.
以上是实现的语句。我想实现下面的功能,如果点击,就出现气泡提示,不点击时不出现。代码如下。
procedure TForm1.Panel1Click(Sender: TObject);
var
aa : THintWin;
bb : Trect;
Button: TMouseButton;
str : string;
begin
aa := THintWin.Create(self);
aa.titlestr := '时间:2006-12-1 9:00:00';
str :='4#:123456' ;
aa.ActivateHint(bb,str);
aa.Free;
end;
问题是:如果点击panel出现气泡提示后,以后只要鼠标移动到panel上,提示都会出现。由于对消息不熟悉,请教高手!
interface
uses
Windows, Messages, Classes, Controls, Forms, CommCtrl;
type
THintWin=class(THintWindow)
private
FLastActive: Tpoint;
public
titlestr : string;
procedure ActivateHint(Rect:TRect;Const AHint:string);override;
end;
implementation
procedure AddTipTool(hWnd: DWORD; IconType: Integer; Title, Text: PChar);
const
TTS_BALLOON =$0040;
TTM_SETTITLE=WM_USER + 32;
var
hWndTip: DWORD;
ToolInfo: TToolInfo;
begin
hWndTip:=CreateWindow(TOOLTIPS_CLASS, nil,
WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
0, 0, 0, 0, hWnd, 0, HInstance, nil);
if (hWndTip<>0) then
begin
ToolInfo.cbSize:=SizeOf(ToolInfo);
ToolInfo.uFlags:=TTF_IDISHWND or TTF_SUBCLASS or TTF_TRANSPARENT;
ToolInfo.uId:=hWnd;
ToolInfo.lpszText:=Text;
SendMessage(hWndTip,TTM_ADDTOOL,1,Integer(@ToolInfo));
SendMessage(hWndTip,TTM_SETTITLE,IconType,Integer(Title));
end;
InitCommonControls();
end;
procedure THintWin.ActivateHint(Rect:TRect;const AHint:string);
begin
if (FLastActive.X<>Mouse.CursorPos.X) or (FLastActive.y<>Mouse.CursorPos.y) then
AddTipTool(WindowFromPoint(Mouse.CursorPos),1,PChar(titlestr), PChar(AHint));//Application.Hint));
FLastActive:=Mouse.CursorPos;
end;
initialization
Application.HintPause:=0;
Application.ShowHint:=False;
HintWindowClass:=THintWin;
Application.ShowHint:=True;
end.
以上是实现的语句。我想实现下面的功能,如果点击,就出现气泡提示,不点击时不出现。代码如下。
procedure TForm1.Panel1Click(Sender: TObject);
var
aa : THintWin;
bb : Trect;
Button: TMouseButton;
str : string;
begin
aa := THintWin.Create(self);
aa.titlestr := '时间:2006-12-1 9:00:00';
str :='4#:123456' ;
aa.ActivateHint(bb,str);
aa.Free;
end;
问题是:如果点击panel出现气泡提示后,以后只要鼠标移动到panel上,提示都会出现。由于对消息不熟悉,请教高手!