unit Unit1;
{
---------------------------
05.04.2006
(C) Copyright 2006 by Benj
[email]benjmeier@bluewin.ch[/email]
EasyPaint v0.1
---------------------------
}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, Spin, ExtDlgs
{, Unit2};
type
TForm1 =
class(TForm)
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Neu1: TMenuItem;
Beenden1: TMenuItem;
Bearbeiten1: TMenuItem;
Werkzeug1: TMenuItem;
Schreiber1: TMenuItem;
Linien1: TMenuItem;
Info1: TMenuItem;
Panel1: TPanel;
ColorBox1: TColorBox;
ColorBox2: TColorBox;
StaticText1: TStaticText;
StaticText2: TStaticText;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Hilfe1: TMenuItem;
About1: TMenuItem;
Label2: TLabel;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
StatusBar1: TStatusBar;
ffnen1: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Speichern1: TMenuItem;
SpinEdit2: TSpinEdit;
StaticText3: TStaticText;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Neu1Click(Sender: TObject);
procedure Beenden1Click(Sender: TObject);
procedure ColorBox2Change(Sender: TObject);
procedure ColorBox1Change(Sender: TObject);
procedure Schreiber1Click(Sender: TObject);
procedure Linien1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Hilfe1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label1MouseLeave(Sender: TObject);
procedure Label1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Label2MouseLeave(Sender: TObject);
procedure Label2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject;
var Key: Char);
procedure ffnen1Click(Sender: TObject);
procedure Speichern1Click(Sender: TObject);
procedure SpinEdit2Change(Sender: TObject);
procedure SpinEdit2KeyPress(Sender: TObject;
var Key: Char);
private
{ Private declarations }
public
Drawing, Zeichnen: Boolean;
Origin, MovePt: TPoint;
Xk, Yk, Move: Integer;
Bitmap, Bitm: TBitmap;
bmps, bmp:
String;
rec: TRect;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Drawing := True;
Canvas.MoveTo(X, Y);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Xk := X - 25;
Yk := Y - 25;
Edit1.Text := '
X: ' + IntToStr (Xk) + '
, Y: ' + IntToStr (Yk);
if Move = 2
then
else
begin
if Drawing
then
Canvas.LineTo(X, Y)
end;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Canvas.LineTo(X, Y);
Drawing := False;
end;
procedure TForm1.Neu1Click(Sender: TObject);
begin
Form1.Color := clBlack;
Form1.Color := clWhite;
Canvas.Pen.Color := clBlack;
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
Canvas.Pen.Color := ColorBox2.Selected;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
Form1.Color := ColorBox1.Selected;
end;
procedure TForm1.Schreiber1Click(Sender: TObject);
begin
Move := 1;
end;
procedure TForm1.Linien1Click(Sender: TObject);
begin
Move := 2;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Move := 1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Move := 2;
end;
procedure TForm1.Hilfe1Click(Sender: TObject);
begin
Form1.Color := clBlack;
Form1.Color := clWhite;
Canvas.Pen.Color := clWhite;
Label2.Caption := '
Hilfe';
Label1.Caption := '
Wie kann ich ein Bild speichern/öffnen?' + #13 + #13 + '
Öffnen: "Datei/Öffnen..." Speichern: Die Bilder können leider noch nicht gespeichert werden.' + #13 + #13 + '
Warum wird das Bild gelöscht, wenn ich das Programm minimiere und dann wieder maximiere?' + #13 + #13 + '
Weil das Bild direkt auf die Applikation gezeichnet wurde.' + #13 + '
Leider kann ich dieses Problem (noch) nicht lösen.' + #13 + #13 + '
Warum wird das Bild gelöscht, wenn ich eine neue Hintergrundfarbe wähle?' + #13 + #13 + '
Weil einfach eine neue Ebene mit der neuen Farbe auf das Bild gelegt wird' + #13 + #13 + #13 + '
Bei weiteren Fragen melden Sie sich bitte bei mir (benjmeier@bluewin.ch).';
end;
procedure TForm1.About1Click(Sender: TObject);
begin
Form1.Color := clBlack;
Form1.Color := clWhite;
Canvas.Pen.Color := clWhite;
Label2.Caption := '
About';
Label1.Caption := '
(C) Copyright 2006 by Benj' + #13 + '
[email]benjmeier@bluewin.ch[/email]' + #13 + '
Dieses Programm ist noch eine BETA-Version und kann somit auch noch Fehler haben.' + #13 + #13 + '
mfG Benj (Nicknames: dsb.8-), toredo)';
end;
procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Label2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Label1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Label2MouseLeave(Sender: TObject);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Label2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Canvas.Pen.Color := clBlack;
Label1.Caption := '
';
Label2.Caption := '
';
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Form1.Color := clBlack;
Form1.Color := clWhite;
Canvas.Pen.Color := clBlack;
ColorBox2.Selected := clBlack;
ColorBox1.Selected := clWhite;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
Key := #0
end;
procedure TForm1.ffnen1Click(Sender: TObject);
begin
if OpenDialog1.Execute
then
begin
bmp := OpenDialog1.FileName;
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile(bmp);
Form1.Canvas.Brush.Bitmap := Bitmap;
Form1.Canvas.FillRect(Rect(25,25,639,390));
finally
Form1.Canvas.Brush.Bitmap :=
nil;
Bitmap.Free;
end;
end;
end;
procedure TForm1.Speichern1Click(Sender: TObject);
begin
{hier sollte der speichern-code sein}
end;
procedure TForm1.SpinEdit2Change(Sender: TObject);
begin
Canvas.Pen.Width:= Form1.SpinEdit2.Value;
end;
procedure TForm1.SpinEdit2KeyPress(Sender: TObject;
var Key: Char);
begin
Key := #0
end;
end.