Ver Mensaje Individual
  #2  
Antiguo 08-01-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Te muestro un ejemplo usando ModalResult:
Crea el formulario que va a ser modal como disponible y no como autocreado.

UNIT1.CPP
Código PHP:
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
  : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  
TForm2 *Dialog = new TForm2(this);
  
TModalResult Result Dialog->ShowModal();
  if(
Result == mrOkShowMessage("OK");
  else if(
Result == mrCancelShowMessage("Cancel");
  else if(
Result == mrOtroShowMessage("Otro");
}
//--------------------------------------------------------------------------- 
UNIT2.H
Código PHP:
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------

TModalResult mrOtro mrNo 1;

class 
TForm2 : public TForm
{
__published:    // IDE-managed Components
  
TButton *Button1;
  
TButton *Button2;
  
TButton *Button3;
  
void __fastcall Button1Click(TObject *Sender);
  
void __fastcall Button2Click(TObject *Sender);
  
void __fastcall Button3Click(TObject *Sender);
private:    
// User declarations
public:        // User declarations
  
__fastcall TForm2(TComponentOwner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif 
UNIT2.CPP
Código PHP:
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponentOwner)
  : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)
{
  
ModalResult mrOk;
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button2Click(TObject *Sender)
{
  
ModalResult mrCancel;
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button3Click(TObject *Sender)
{
  
ModalResult mrOtro;
}
//--------------------------------------------------------------------------- 
Saludos.
Responder Con Cita