Desenhar formas geométricas no C++ builder
é tarefa muito fácil, podemos arrastar e soltar
os componentes, ou criá-los na mão inserindo códigos.
Neste exemplo preferi arrastar e soltar no form,
acessando as propriedades de cada elemento,
personalizando de acordo com o que achei necessário.
Veja os códigos abaixo a maioria gerados pelo programa:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "OnPaint.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1 ( TComponent* Owner ) :
TForm ( Owner ) {
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnPaint ( TObject *Sender ) {
Label1 -> Caption = "C++ BUILDER - DESENHANDO FORMAS GEOMÉTRICAS";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SairClick(TObject *Sender)
{
Close ( );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef OnPaintH
#define OnPaintH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Sair;
TShape *Shape1;
TShape *Shape2;
TShape *Shape3;
TShape *Shape4;
TShape *Shape5;
TShape *Shape6;
TShape *Shape7;
TShape *Shape8;
TShape *Shape9;
TShape *Shape10;
TShape *Shape11;
TLabel *Label1;
void __fastcall OnPaint(TObject *Sender);
void __fastcall SairClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
object Form1: TForm1
Left = 342
Top = 219
Width = 607
Height = 328
AutoScroll = True
Caption = 'C++ BUILDER - DESENHANDO FORMAS GEOM'#201'TRICAS'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesigned
OnPaint = OnPaint
PixelsPerInch = 96
TextHeight = 13
object Shape1: TShape
Left = 48
Top = 48
Width = 65
Height = 65
Brush.Color = clBlue
end
object Shape2: TShape
Left = 48
Top = 160
Width = 65
Height = 66
Brush.Style = bsClear
Pen.Color = clAqua
Pen.Style = psDash
Pen.Width = 5
end
object Shape3: TShape
Left = 144
Top = 80
Width = 65
Height = 33
Brush.Color = clRed
end
object Shape4: TShape
Left = 144
Top = 192
Width = 65
Height = 33
Pen.Color = clBlue
Pen.Width = 5
end
object Shape5: TShape
Left = 248
Top = 48
Width = 65
Height = 65
Brush.Color = clFuchsia
Shape = stCircle
end
object Shape6: TShape
Left = 248
Top = 160
Width = 65
Height = 65
Brush.Color = clGreen
Pen.Color = clRed
Pen.Width = 5
Shape = stCircle
end
object Shape7: TShape
Left = 368
Top = 64
Width = 97
Height = 49
Brush.Color = clLime
Shape = stEllipse
end
object Shape8: TShape
Left = 368
Top = 176
Width = 97
Height = 49
Brush.Color = clAqua
Pen.Width = 5
Shape = stEllipse
end
object Shape9: TShape
Left = 471
Top = 64
Width = 97
Height = 49
Brush.Color = clYellow
Shape = stRoundSquare
end
object Shape10: TShape
Left = 471
Top = 176
Width = 97
Height = 49
Brush.Color = clBlack
Pen.Color = clYellow
Pen.Width = 5
Shape = stRoundSquare
end
object Shape11: TShape
Left = 0
Top = 0
Width = 590
Height = 290
Brush.Style = bsClear
Pen.Width = 10
Shape = stRoundRect
end
object Label1: TLabel
Left = 32
Top = 16
Width = 60
Height = 25
Caption = 'Label1'
Font.Charset = DEFAULT_CHARSET
Font.Color = clRed
Font.Height = -21
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ParentFont = False
end
object Sair: TButton
Left = 264
Top = 248
Width = 75
Height = 25
Caption = 'Sair'
TabOrder = 0
OnClick = SairClick
end
end
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.