Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Draw a line from the mouse cursor to a fixed point on a form Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Sep-03
Category
VCL-Forms
Language
Delphi 2.x
Views
200
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to draw a line from the mouse cursor to a fixed point on a form 

Answer:

1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
7   
8   type
9     TForm1 = class(TForm)
10      procedure FormCreate(Sender: TObject);
11      procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
12    private
13      { Private declarations }
14      fOldX, fOldY: Integer;
15      fLineDrawn: Boolean;
16    public
17      { Public declarations }
18    end;
19  
20  var
21    Form1: TForm1;
22  
23  implementation
24  
25  {$R *.DFM}
26  
27  procedure TForm1.FormCreate(Sender: TObject);
28  begin
29    fLineDrawn := false;
30  end;
31  
32  procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
33  
34    procedure DrawLine(Color: TColor);
35    begin
36      Canvas.Pen.Color := Color;
37      Canvas.MoveTo(fOldX, fOldY);
38      Canvas.LineTo(100, 100);
39    end;
40  
41  begin
42    if fLineDrawn then
43      DrawLine(Color);
44    fOldX := X;
45    fOldY := Y;
46    DrawLine(clRed);
47    fLineDrawn := true;
48  end;
49  
50  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC