Curso de C++ Builder


Estructura y configuración de un proyecto


Fichero "main.cpp"

 
//----------------------------------------------------------------- 
#include <vcl.h>
#pragma hdrstop 
 
#include "main.h" 
//----------------------------------------------------------------- 
#pragma package(smart_init) 
#pragma resource "*.dfm" 
TMainForm *MainForm; 
//----------------------------------------------------------------- 
__fastcall TMainForm::TMainForm(TComponent* Owner) 
   : TForm(Owner) 
{ 
} 
//----------------------------------------------------------------- 
void __fastcall TMainForm::ExitButtonClick(TObject *Sender) 
{ 
   Application->Terminate(); 
} 
//----------------------------------------------------------------- 
void __fastcall TMainForm::FormCreate(TObject *Sender) 
{ 
 
   MainForm->Caption = "Primer programa con C++ Builder"; 
 
   if (MainForm->Color == clBtnFace) 
      MainForm->Color = clWhite; 
 
   CheckBox->Checked = false; 
 
 
   RadioButton1->Hide(); 
   RadioButton2->Hide(); 
 
} 
//----------------------------------------------------------------- 
void __fastcall TMainForm::CheckBoxClick(TObject *Sender) 
{ 
   if (CheckBox->Checked == true) { 
      RadioButton1->Show(); 
      RadioButton2->Show(); 
      RadioButton1->Checked = true; 
      OKButton->Enabled = true; 
   } 
   else { 
      RadioButton1->Hide(); 
      RadioButton2->Hide(); 
      OKButton->Enabled = false; 
      LabelOutput->Caption = ""; 
   } 
 
} 
//----------------------------------------------------------------- 
void __fastcall TMainForm::OKButtonClick(TObject *Sender) 
{ 
 
   if (RadioButton1->Checked) { 
      if (Edit->Text == "") 
         LabelOutput->Caption = "Escogió Opción 1, Sr/Sra. desconocido/a"; 
      else 
         LabelOutput->Caption = "Escogió Opción 1, Sr/Sra. " + Edit->Text; 
   } 
   else { 
      if (Edit->Text == "") 
         LabelOutput->Caption = "Escogió Opción 2, Sr/Sra. desconocido/a"; 
      else 
         LabelOutput->Caption = "Escogió Opción 2, Sr/Sra. " + Edit->Text; 
   } 
 
} 
//----------------------------------------------------------------- 

 



Atrás