 |
|
|
Informatik |
|
Autor: be
21.09.2005 10:49 436
|
|
|
Haus - Lösung
Der manuell geschriebene Quelltext ist blau hervorgehoben.
unit mHaus;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private-Deklarationen }
x1, y1: Integer;
procedure haus(x,y, breite, hoehe: Integer; farbe: TColor);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.haus(x,y, breite, hoehe: Integer; farbe: TColor);
begin
with Image1.Canvas do
begin
Brush.Color := farbe;
Rectangle(x, y, x + breite, y - (hoehe*2) div 3);
Polygon([Point(x, y - (hoehe*2) div 3),
Point(x + breite div 2, y - hoehe),
Point(x + breite, y - (hoehe*2) div 3)]);
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
x1 := X;
y1 := Y
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
haus(x1, y1, X - x1, y1 - Y, clBlue)
end;
end.