1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, Menus, XPMan;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button2: TButton;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
Fermer1: TMenuItem;
Apropos1: TMenuItem;
StatusBar1: TStatusBar;
Button1: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
XPManifest1: TXPManifest;
Button4: TButton;
Memo1: TMemo;
Button5: TButton;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Déclarations privées }
public
{ Déclarations publiques }
drawing:boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var but:TButton ;
sha:tshape;
begin
if Statusbar1.SimpleText='Création maitre' then
begin
but:= TButton.Create(self); //self a la place de form
but.Caption := 'Maitre';
but.Width := 50;
but.Height := 20;
but.Top := y;
but.Left := x;
but.Visible := True;
but.Parent := Form1; //ajouter aussi ça
end;
if Statusbar1.SimpleText='Création esclave' then
begin
but:= TButton.Create(self); //self a la place de form
but.Caption := 'Esclave';
but.Width := 50;
but.Height := 20;
but.Top := y;
but.Left := x;
but.Visible := True;
but.Parent := Form1; //ajouter aussi ça
end;
if Statusbar1.SimpleText='Création bus' then
begin
sha:= Tshape.Create(self); //self a la place de form
sha.Width := 150;
sha.Height := 40;
sha.Top := y;
sha.Left := x;
sha.Visible := True;
sha.Parent := Form1;
sha.Shape:=strectangle;
end;
if statusbar1.SimpleText='Création lien' then
begin
with form1.canvas do
begin
pen.width:=1;
pen.color:=clblack;
drawing:=true;
moveto(x,y);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Statusbar1.SimpleText:='Création maitre';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Statusbar1.SimpleText:='Création esclave';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Statusbar1.SimpleText:='Création bus';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Statusbar1.SimpleText:='Création lien';
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if statusbar1.SimpleText='Création lien' then
begin
If drawing
then with form1 do
begin
// cursor:=crNone; {to keep cursor redraw from erasing part of our line}
canvas.lineto(x,y);
// cursor:=crdefault;
end;
end;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if statusbar1.SimpleText='Création lien' then
drawing:=false;
end;
end. |
Partager