我简单写了个例子,基本能够实现:<br><br>工程文件<br>-----------------------------------------------------<br>program Project1;<br><br>uses<br> Forms,<br> Unit1 in 'Unit1.pas' {Form1},<br> Unit2 in 'Unit2.pas' {Form2};<br><br>{$R *.RES}<br><br>begin<br> Application.Initialize;<br> Application.CreateForm(TForm1, Form1);<br> Application.CreateForm(TForm2, Form2);<br> Application.Run;<br>end.<br><br><br>主窗体:*.pas<br>--------------------------------------------------<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Timer1: TTimer;<br> procedure FormMouseDown(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br> PShow:TPoint;<br><br>implementation<br><br>uses Unit2;<br><br>{$R *.DFM}<br><br>procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br>begin //点击鼠标显示提示窗体<br> //获取当前鼠标坐标<br> GetCursorPos(PShow);<br><br> //定位显示提示窗体<br> Form2.Left:=PShow.X+5; //这里取偏移5显示<br> Form2.Top:=PShow.Y+5; //这里取偏移5显示<br> Form2.Show;<br><br> //启动延时检测是否该关闭提示窗体<br> Timer1.Enabled:=false;<br> Timer1.Interval:=1000; //这里取1秒定时周期<br> Timer1.Enabled:=true;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var P:TPoint;<br>begin<br> if not Form2.Visible then<br> begin //如果提示窗体已经关闭,则终止定时<br> Timer1.Enabled:=false;<br> exit;<br> end;<br><br> //获取当前鼠标坐标<br> GetCursorPos(P);<br> if ((Abs(PShow.X-P.X)>5) or (Abs(PShow.Y-P.Y)>5)) then<br> begin //如果鼠标的偏移量超过某一个限度(这里取5,可以根据实际情况调整)<br> if (P.X<Form2.Left) or<br> (P.X>Form2.Left+Form2.Width) or<br> (P.Y<Form2.Top) or<br> (P.Y>Form2.Top+Form2.Height) then<br> begin //鼠标位置不在提示窗体范围内<br> Timer1.Enabled:=false; //终止定时<br> Form2.Close; //关闭提示窗体<br> end;<br> end;<br>end;<br><br>end.<br><br>主窗体:*.dfm<br>------------------------------------------<br>object Form1: TForm1<br> Left = 272<br> Top = 237<br> Width = 450<br> Height = 361<br> Caption = 'Form1'<br> Color = clBtnFace<br> Font.Charset = DEFAULT_CHARSET<br> Font.Color = clWindowText<br> Font.Height = -11<br> Font.Name = 'MS Sans Serif'<br> Font.Style = []<br> OldCreateOrder = False<br> OnMouseDown = FormMouseDown<br> PixelsPerInch = 96<br> TextHeight = 13<br> object Timer1: TTimer<br> Enabled = False<br> OnTimer = Timer1Timer<br> Left = 100<br> Top = 16<br> end<br>end<br><br>提示窗体:*.pas<br>-----------------------------------------------<br>unit Unit2;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, Buttons;<br><br>type<br> TForm2 = class(TForm)<br> SpeedButton1: TSpeedButton;<br> Label1: TLabel;<br> procedure SpeedButton1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form2: TForm2;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm2.SpeedButton1Click(Sender: TObject);<br>begin //关闭按钮<br> Close;<br>end;<br><br>end.<br><br>提示窗体:*.dfm <br>设为 AutoSize = True BorderStyle = bsNone <br>-------------------------------------------<br>object Form2: TForm2<br> Left = 516<br> Top = 164<br> AutoSize = True<br> BorderStyle = bsNone<br> BorderWidth = 2<br> Caption = 'Form2'<br> ClientHeight = 71<br> ClientWidth = 163<br> Color = 11599871<br> Font.Charset = DEFAULT_CHARSET<br> Font.Color = clWindowText<br> Font.Height = -11<br> Font.Name = 'MS Sans Serif'<br> Font.Style = []<br> OldCreateOrder = False<br> PixelsPerInch = 96<br> TextHeight = 13<br> object SpeedButton1: TSpeedButton<br> Left = 0<br> Top = 0<br> Width = 23<br> Height = 22<br> Flat = True<br> OnClick = SpeedButton1Click<br> end<br> object Label1: TLabel<br> Left = 1<br> Top = 32<br> Width = 162<br> Height = 39<br> Caption = <br> ' 演示数据 演示数据 演示数据 '#13#10' 演示数据 演示数据 演示数据 '#13#10 +<br> ' '<br> end<br>end