You are on page 1of 4

TALLER # 2

CALCULO DE AREAS DE FIGURAS

OBJETOS UTILIZADOS

NOMBRE DEL OBJETO PROPIEDADES


LABEL (STANDARD) CAPTION
FONT
COLOR
EDIT STANDARD) TEXT
FONT
COLOR
VISIBLE
BITBTN (ADDITIONAL) CAPTION
CURSOR
GLYPH
ENABLED
IMAGE (ADDITIONAL) PICTURE
VISIBLE
COMBOBOX (STANDARD) TEXT
FONT
ITEMS
STATICTEXT (ADDITIONAL) CAPTION
FONT
GROUPBOX (STANDARD) CAPTION
FONT

Práctica de Informática - Programación con Delphi - Taller # 2 Página 1 de 4


CODIGO FUENTE – EVENTO ON CHANGE DEL OBJETO COMBOBOX

procedure TForm1.ComboBox1Change(Sender: TObject);


VAR fig : integer;
begin
bitbtn1.enabled := true;
fig := combobox1.itemindex;
case fig of
0 : begin
image1.visible := true;
image2.visible := false;
image3.visible := false;
label3.caption := 'Base :';
label3.visible := true;
edit1.visible := true;
label4.visible := true;
label5.Caption := 'Altura :';
label5.visible := true;
edit2.visible := true;
label6.visible := true;
label7.Caption := '';
label7.visible := false;
edit3.visible := false;
label8.visible := false;
end;
1 : begin
image1.visible := false;
image2.visible := true;
image3.visible := false;
label3.caption := 'Base :';
label3.visible := true;
edit1.visible := true;
label4.visible := true;
label5.Caption := 'Altura :';
label5.visible := true;
edit2.visible := true;
label6.visible := true;
label7.Caption := '';
label7.visible := false;
edit3.visible := false;
label8.visible := false;
end;
2 : begin
image1.visible := false;
image2.visible := false;
Práctica de Informática - Programación con Delphi - Taller # 2 Página 2 de 4
image3.visible := true;
label3.caption := 'Base Menor :';
label3.visible := true;
edit1.visible := true;
label4.visible := true;
label5.Caption := 'Base Mayor :';
label5.visible := true;
edit2.visible := true;
label6.visible := true;
label7.Caption := 'Altura :';
label7.visible := true;
edit3.visible := true;
label8.visible := true;
end;
end;
end;

CODIGO FUENTE DEL BOTON CALCULAR

procedure TForm1.BitBtn1Click(Sender: TObject);


var fig : integer;
area, d1, d2, d3 : real;
begin
bitbtn1.enabled := false;
bitbtn2.enabled := true;
fig := combobox1.itemindex;
case fig of
0 : begin
d1 := strtofloat(edit1.text);
d2 := strtofloat(edit2.text);
area := d1*d2;
end;
1 : begin
d1 := strtofloat(edit1.text);
d2 := strtofloat(edit2.text);
area := d1*d2/2;
end;
2 : begin
d1 := strtofloat(edit1.text);
d2 := strtofloat(edit2.text);
d3 := strtofloat(edit3.text);
area := (d1+d2)*d3/2;
end;
end;
statictext1.caption := 'Area = ' + floattostr(area) + ' cms2';
groupbox2.visible := true;
end;

Práctica de Informática - Programación con Delphi - Taller # 2 Página 3 de 4


CODIGO FUENTE DEL BOTON LIMPIAR

procedure TForm1.BitBtn2Click(Sender: TObject);


begin
combobox1.Text := '';
edit1.text := '';
edit2.text := '';
edit3.text := '';
edit1.visible := false;
edit2.visible := false;
edit3.visible := false;
label3.visible := false;
label4.visible := false;
label5.visible := false;
label6.visible := false;
label7.visible := false;
label8.visible := false;
groupbox2.visible := false;
bitbtn1.enabled := false;
bitbtn2.enabled := false;
image1.visible := false;
image2.visible := false;
image3.visible := false;
end;

CODIGO FUENTE DEL BOTON SALIR

procedure TForm1.BitBtn3Click(Sender: TObject);


begin
close;
end;

Práctica de Informática - Programación con Delphi - Taller # 2 Página 4 de 4

You might also like