我在网上搜索了一个程序,但它是跟随鼠标显示的,我想让它在制定控件上显示,例如在Edit1里显示,我改如何改呢?
那位大哥能帮改成不用放鼠标就能显示提示呢?谢谢原代码
unit Sherryhint;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,CommCtrl; type
THintWin = class(THintWindow)
private
FLastActive: THandle;
public
procedure ActivateHint(Rect:TRect;Const AHint:string);override;
end; implementationuses Unit1;
{ THintWin }
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
inherited;
if FLastActive <> WindowFromPoint(Mouse.CursorPos) then
AddTipTool(WindowFromPoint(Mouse.CursorPos),1,'提示', PChar(AHint));//Application.Hint));
FLastActive:=WindowFromPoint(Mouse.CursorPos);
end; initialization
Application.HintPause:=0;
Application.ShowHint:=False;
HintWindowClass:=THintWin;
Application.ShowHint:=True; end.
那位大哥能帮改成不用放鼠标就能显示提示呢?谢谢原代码
unit Sherryhint;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,CommCtrl; type
THintWin = class(THintWindow)
private
FLastActive: THandle;
public
procedure ActivateHint(Rect:TRect;Const AHint:string);override;
end; implementationuses Unit1;
{ THintWin }
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
inherited;
if FLastActive <> WindowFromPoint(Mouse.CursorPos) then
AddTipTool(WindowFromPoint(Mouse.CursorPos),1,'提示', PChar(AHint));//Application.Hint));
FLastActive:=WindowFromPoint(Mouse.CursorPos);
end; initialization
Application.HintPause:=0;
Application.ShowHint:=False;
HintWindowClass:=THintWin;
Application.ShowHint:=True; end.
解决方案 »
- 关于ADODataSet或者DBEdit的问题
- Delphi 中Quick Report和Rav Report都不能连接Access类型的数据库吗?
- 为何SOCKET接收到PCHAR类型数据无法读取?
- 100分求ADO+ACCESS源码,不够再加,!!!!!!!急急
- 怎么存取图像,在sql 2000里边
- 关于listview滚动条同步的问题,好像还没有解决的先例,进来看看吧!谁能给予解决的,我愿意给1000分!
- 200分求解决用LQ-300K打印商场的收银单纸张设置的难题
- 请问,Lcstring Lcsystem 这些都是什么组件??
- delphi6 自动退出的问题?
- 好酒好菜又上來,高手請進,不必客气慢慢用!
- 求助:如何将一个C++类转换成Delphi代码
- delphi bypass 是什么意思
begin
inherited;
if FLastActive <> WindowFromPoint(Mouse.CursorPos) then
AddTipTool(WindowFromPoint(Mouse.CursorPos),1,'提示', PChar(AHint));//Application.Hint));
FLastActive:=WindowFromPoint(Mouse.CursorPos);
end;
如老孟同志说的一样,主要是这里的Tpoint 是从 Mouse.CusorPos取了.
取Edit1左上角的坐标
var
p:TPoint;
begin
p := Point(Edit1.Left,Edit1.Top)
end;将Mouse.CursorPos 替换成 p
我试过了不行呀,能不能帮我试试,小弟谢谢了
哈哈好像是在给jvcl做广告