FAQ | Points | Add... | Recent posts | Search | Register | Log in


Program do rysowania w delphi


Post new topic  Reply to topic      Main Page -> Forum Index -> Programming Generally -> Program do rysowania w delphi
Author
Message
Thomas1988
Poziom 15
Poziom 15


Joined: 25 May 2005
Posts: 232
Location: Gniezno/Poznań

Post#1 Post from the author of the topic 17 Mar 2007 10:17   

Program do rysowania w delphi


Mam duży problem i nie wiem co z tym zrobić :cry:


Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ColorGrd, ExtDlgs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PaintBox1: TPaintBox;
    ListBox1: TListBox;
    ListBox2: TListBox;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    ComboBox2: TComboBox;
    Panel1: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    SavePictureDialog1: TSavePictureDialog;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure ListBox2Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
PaintBox1.Canvas.Rectangle(10,10,(StrToInt(edit1.text)),(StrToInt(edit2.text)));
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
if ListBox1.ItemIndex= 0
then PaintBox1.Canvas.Brush.Color:=ClBlue;
if ListBox1.ItemIndex= 1
then PaintBox1.Canvas.Brush.Color:=ClYellow;
if ListBox1.ItemIndex= 2
then PaintBox1.Canvas.Brush.Color:=ClRed;
if ListBox1.ItemIndex= 3
then PaintBox1.Canvas.Brush.Color:=ClGreen;
if ListBox1.ItemIndex= 4
then PaintBox1.Canvas.Brush.Color:=ClBlack;
end;
procedure TForm1.ListBox2Click(Sender: TObject);
begin
if ListBox2.ItemIndex= 0
then PaintBox1.Canvas.Pen.Color:=ClBlue;
if ListBox2.ItemIndex= 1
then PaintBox1.Canvas.Pen.Color:=ClYellow;
if ListBox2.ItemIndex= 2
then PaintBox1.Canvas.Pen.Color:=ClRed;
if ListBox2.ItemIndex= 3
then PaintBox1.Canvas.Pen.Color:=ClGreen;
if ListBox2.ItemIndex= 4
then PaintBox1.Canvas.Pen.Color:=ClBlack;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.ItemIndex= 0
then PaintBox1.Canvas.Pen.Width:=1;
if ComboBox1.ItemIndex= 1
then PaintBox1.Canvas.Pen.Width:=2;
if ComboBox1.ItemIndex= 2
then PaintBox1.Canvas.Pen.Width:=3;
if ComboBox1.ItemIndex= 3
then PaintBox1.Canvas.Pen.Width:=4;
if ComboBox1.ItemIndex= 4
then PaintBox1.Canvas.Pen.Width:=5;
if ComboBox1.ItemIndex= 5
then PaintBox1.Canvas.Pen.Width:=6;
if ComboBox1.ItemIndex= 6
then PaintBox1.Canvas.Pen.Width:=7;
if ComboBox1.ItemIndex= 7
then PaintBox1.Canvas.Pen.Width:=8;
if ComboBox1.ItemIndex= 8
then PaintBox1.Canvas.Pen.Width:=9;


end;


procedure TForm1.ComboBox2Change(Sender: TObject);
begin
if ComboBox2.ItemIndex= 0
then PaintBox1.Canvas.Brush.Style:=bsSolid;
if ComboBox2.ItemIndex= 1
then PaintBox1.Canvas.Brush.Style:=bsCross;
if ComboBox2.ItemIndex= 2
then PaintBox1.Canvas.Brush.Style:=bsClear;
if ComboBox2.ItemIndex= 3
then PaintBox1.Canvas.Brush.Style:=bsDiagCross;
if ComboBox2.ItemIndex= 4
then PaintBox1.Canvas.Brush.Style:=bsHorizontal;
if ComboBox2.ItemIndex= 5
then PaintBox1.Canvas.Brush.style:=bsVertical;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if savepicturedialog1.Execute then
PaintBox1.Picture.SaveToFile(SavePictureDialog1.Filename);


Napisałem taki program.
1. Nie wiem czemu nie chce zapisać obrazka za pomoc± funkcji savepicturedialog ?
2. Jak zrobić, żeby kolory funkcji Pen i Brush pobierał z colordialog ?
No i trzecia sprawa koło zawsze jest rysowane na pocz±tku okna PaintBox jest może jaka¶ komenda dzięki której można by pobierać współrzędne miejsca rysowania przez kliknięcie myszki. Wiem, że do tego służy funkcja MoveToLine
Proszę o pomoc dopiero zaczynam przygodę z programowaniem :|
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 17 Mar 2007 10:17   





Back to top
   
Thomas1988
Poziom 15
Poziom 15


Joined: 25 May 2005
Posts: 232
Location: Gniezno/Poznań

Post#2 Post from the author of the topic 17 Mar 2007 19:30   

Re: Program do rysowania w delphi


Nikt nie ma pomysłu :?:
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 17 Mar 2007 19:30   





Back to top
   
radziow
Poziom 13
Poziom 13


Joined: 02 Aug 2005
Posts: 116
Location: Kraków

Post#3 20 Mar 2007 12:45   

Re: Program do rysowania w delphi


1. Zapis
bmp:=TBitmap.Create;
bmp.canvas.Assign(PainBox1.Canvas);
bmp.SaveToFile('nazwaPliku.bmp');

2.
PaintBox.Canvas.Pen.Color:=ColorDialog1.Color;
3.
w zdarzeniu PaintBox.OnMouseDown
begin
PainBox1.Canvas.Rectangle(X,Y,100,100);
end;
Back to top
   
Post new topic  Reply to topic      Main Page -> Forum Index -> Programming Generally -> Program do rysowania w delphi
Page 1 of 1
Similar topics
Program do rysowania schematow ideowych. (5)
Program do rysowania schematów PROTEL (4)
program do rysowania schenatów elektrycznych (2)
Jaki program do rysowania schematów? (17)
Program do rysowania schematów... ? (4)
Program do rysowania płytek. (3)
program do rysowania sch. (2)
Program do rysowania ścieżek (7)
Delphi: nadpisywanie procedur rysowania (procedure TForm1.FormPaint) (2)
Jaki program do rysowania schematów (14)

Page generation time: 0.064 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed