在很多软件中(比如:WPS OFFICE),当鼠标移动时,会有一个以鼠标所在点为原点的虚线的坐标系来表明当前鼠标的位置,这两条线是怎样画的?希望高手们帮帮我啊!
解决方案 »
- 创建拨号连接
- RichEdit 中的关键字用红颜色出来(已实现),如何鼠标悬浮到关键字上后把该关键字提取出来,并弹出对话框呢
- 在delphi裡如何實現PORTMAP(端口映射)?
- 双击文件夹 运行程序
- 急用!!
- 我的一个dbgrid的连到一个datasource名是dtds,然后dtds的dataset是一个adoquery,现在当我在dbgrid上选择了几个记录后,如何把所有被选择
- 如何在创建表之前先检测一下,如果存在????
- Params.ExStyle做了什么防止闪烁?
- delphi与网站连接的问题
- DelPHi中使用Agent控件为什么不能非要指定路径acs文件不能用缺省放在同一目录下的acs文件?
- 关于类型库编辑器的问题
- 谁有用Delphi中的ADO连接Access的代码阿,给我一个?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses Unit2;var myline:TMouseLine;{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
myline:=TMouseLine.Create (self,self.PaintBox1.Canvas);
myline.ClientWidth := self.Width;
myline.ClientHeight := self.Height;
end;procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
myline.ReLine (x,y);
end;procedure TForm1.FormResize(Sender: TObject);
begin
myline.ClientWidth := self.Width;
myline.ClientHeight := self.Height;
end;end.{ 以下是自定义的类 TMouseLine 的单元 unit2.pas }
unit Unit2;interfaceuses Graphics, Controls, Classes;type TMouseLine = Class (TGraphicControl)
private
ox,oy:integer;
FCanvas:TCanvas;
FWidth, FHeight:integer;
public
procedure ReLine (x,y:Integer);
constructor Create (AOwner:TComponent;Canvas:TCanvas);
destructor Destroy; override;
published
property ClientWidth: integer read FWidth write FWidth;
property ClientHeight: Integer read FHeight write FHeight;
end;implementationconstructor TMouseLine.Create(AOwner:TComponent;Canvas:TCanvas);
begin
inherited Create(AOwner);
FCanvas:=Canvas;
FWidth:=0;
FHeight:=0;
ox:=0;oy:=0;
end;destructor TMouseLine.Destroy;
begin
inherited Destroy;
end;procedure TMouseLine.ReLine(x,y:Integer);
begin
with FCanvas do begin
pen.Color := clBtnFace;
pen.Width := 1;
MoveTo (ox,0);
LineTo (ox,FHeight);
MoveTo (0,oy);
LineTo (FWidth,oy); pen.Color := clBlack;
pen.Width := 1;
MoveTo (x,0);
LineTo (x,FHeight);
MoveTo (0,y);
LineTo (FWidth,y);
end;
ox:=x;oy:=y;
end;end.
刚才我把问题想复杂了,说要用线程,其实没有必要,不好意思.