Ver Mensaje Individual
  #9  
Antiguo 01-10-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola aguml.

No estoy diciendo que esté mal usar WndProc, lo que sucede es que Builder ya tiene definido ese mensaje y te evitas la comprobación de si el mensaje fué otro.

A ver si este ejemplo te dá otra idea... En el form emisor pone un TButton y un TCheckBox y en el receptor tres TCheckBox (CheckBox1, CheckBox2 y CheckBox3) .

Emisor:
Código PHP:
...
struct data_struct {
  
char className[255];
  
char caption[255];
  
int x, y;
  
TColor color;
  
bool state;
} 
ds;

void __fastcall TfrmSender::Button1Click(TObject *Sender)
{
  
HANDLE hRecept = FindWindow("TfrmReceiver", "Receiver");
  if (
hRecept != 0) {
    
COPYDATASTRUCT cds;
    
strcpy(ds.className, "TCheckBox");  
    
strcpy(ds.caption,"CheckBox2");     
    
ds.x = 50;
    
ds.y = 30;
    
ds.color = clYellow;
    
ds.state = CheckBox1->Checked;
    
cds.dwData = 0;
    
cds.cbData = sizeof(ds);
    
cds.lpData = &ds;
    
ShowWindow(hRecept, SW_SHOW);
    
SetForegroundWindow(hRecept);
    
SendMessage(hRecept, WM_COPYDATA, 0, (LPARAM)& cds);
  } else
    
MessageBox(0,"Receptor no encontrado","", MB_ICONERROR);
} 
Receptor:

header
Código PHP:
class TfrmReceiver : public TForm
{
__published:
  
TCheckBox *CheckBox1;
  
TCheckBox *CheckBox2;
  
TCheckBox *CheckBox3;

private:
  
void __fastcall OnWMCopyData(TWMCopyData& msg);

protected:
  
BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER
(WM_COPYDATA, TWMCopyData, OnWMCopyData)
  
END_MESSAGE_MAP(TForm)

public:
  
__fastcall TfrmReceiver(TComponent* Owner);
}; 
code
Código PHP:
struct data_struct {
  
char className[255];
  
char caption[255];
  
int x, y;
  
TColor color;
  
bool state;
} 
ds;

void __fastcall TfrmReceiver::OnWMCopyData(TWMCopyData& msg)
{
  
memcpy(&ds, msg.CopyDataStruct->lpData, sizeof(data_struct));

  for(
int i = 0; i < ComponentCount; i++) {
    
TCheckBox *cb = static_cast<TCheckBox*>(Components[i]);
    if (
cb->ClassNameIs(ds.className) && cb->Caption == ds.caption) {
      
cb->Left    = ds.x;
      
cb->Top     = ds.y;
      
cb->Color   = ds.color;
      
cb->Checked = ds.state;
    }
  }
} 
Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita