Post on 20-Jan-2017
PROYECTOS VCL CON DELPHI
I. Creación de un Proyecto VCL
Paso 1: Creamos una VCL Forms Application.
Paso 2: Personalizamos el Formulario:
Paso 3: Insertamos un TEdit desde la pestaña Standard al formulario y lo
personalizamos:
Propiedad Valor
Name frmCalculadora
Caption MyCalc v1.0
BorderIcons.biMaximize false
BorderStyle bsSingle
Position poScreenCenter
Height / Width 338 / 310
PROYECTOS VCL CON DELPHI
Paso 4: Insertamos 10 componentes Tbutton correspondientes a los números
del 0 al 9, luego los personalizamos:
o Botón 0:
Propiedad Valor
Name txtLED
Alignment taRightJustify
Text ‘’
Font.size 12
Font.Style.fsBold True
Left / Top 17 / 24
Propiedad Valor
Name btn0
Caption 0
Height / Width 42 / 49
Left / Top 17 / 255
PROYECTOS VCL CON DELPHI
Paso 4:
o Botón 1:
o Botón 2:
Propiedad Valor
Name btn1
Caption 1
Height / Width 42 / 49
Left / Top 17 / 208
Propiedad Valor
Name btn2
Caption 2
Height / Width 42 / 49
Left / Top 72 / 208
PROYECTOS VCL CON DELPHI
Paso 4:
o Botón 3:
o Botón 4:
Propiedad Valor
Name btn3
Caption 3
Height / Width 42 / 49
Left / Top 127 / 208
Propiedad Valor
Name btn4
Caption 4
Height / Width 42 / 49
Left / Top 17 / 159
PROYECTOS VCL CON DELPHI
Paso 4:
o Botón 5:
o Botón 6:
Propiedad Valor
Name btn5
Caption 5
Height / Width 42 / 49
Left / Top 72 / 159
Propiedad Valor
Name btn6
Caption 6
Height / Width 42 / 49
Left / Top 127 / 159
PROYECTOS VCL CON DELPHI
Paso 4:
o Botón 7:
o Botón 8:
Propiedad Valor
Name btn7
Caption 7
Height / Width 42 / 49
Left / Top 17 / 112
Propiedad Valor
Name btn8
Caption 8
Height / Width 42 / 49
Left / Top 72 / 112
PROYECTOS VCL CON DELPHI
Paso 4:
o Botón 9:
Paso 5: Hasta este punto deberíamos tener un diseño como el siguiente:
Propiedad Valor
Name btn9
Caption 9
Height / Width 42 / 49
Left / Top 127 / 112
PROYECTOS VCL CON DELPHI
Paso 6: Agregamos 4 TButton mas para las operaciones matemáticas:
o Botón /:
o Botón *:
Propiedad Valor
Name btndiv
Caption /
Height / Width 42 / 49
Left / Top 183 / 112
Propiedad Valor
Name btnpor
Caption *
Height / Width 42 / 49
Left / Top 183 / 159
PROYECTOS VCL CON DELPHI
Paso 6: Agregamos 4 TButton mas para las operaciones matemáticas:
o Botón -:
o Botón +:
Propiedad Valor
Name btnmenos
Caption -
Height / Width 42 / 49
Left / Top 183 / 208
Propiedad Valor
Name btnmas
Caption +
Height / Width 42 / 49
Left / Top 183 / 255
PROYECTOS VCL CON DELPHI
Paso 7: Agregamos 1 TButton para el punto (.):
o Botón .:
Botón 8: Agregamos 1 TButton para el igual (=):
Propiedad Valor
Name btnpunto
Caption .
Height / Width 42 / 49
Left / Top 72 / 255
Propiedad Valor
Name btnigual
Caption =
Height / Width 42 / 49
Left / Top 239 / 255
PROYECTOS VCL CON DELPHI
Paso 9: Agregamos 1 TButton para el Cancel (C):
o Botón .:
Botón 10: Deberíamos tener un parecer a la siguiente imagen:
Propiedad Valor
Name Btncancel
Caption C
Height / Width 42 / 49
Left / Top 239 / 112
PROYECTOS VCL CON DELPHI
Paso 11: Ahora que hemos terminado de distribuir los componentes en el
formulario, debemos programar el comportamiento de cada uno de ellos
cuando el usuario haga click.
El Comportamiento de los botones 0..9 es bastante similar, de modo que aquí
solamente colocaremos 0 y 1 asumiendo que usted comprende como continuar
con los botones 2..9:
o Evento Click del Botón 0:
o Evento Click del Botón 1:
PROYECTOS VCL CON DELPHI
Paso 12: Vamos a declarar 2 variables globales que nos servirán para
almacenar el numero y para seleccionar el tipo de operación a realizar:
Paso 13: Evento Click del botón Cancel:
Paso 14: Evento Click del botón +/-:
PROYECTOS VCL CON DELPHI
Paso 15: Evento Click del botón /:
Paso 16: Evento Click del botón *:
Paso 17: Evento Click del botón -: