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 xy;
  
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.50;
    
ds.30;
    
ds.color clYellow;
    
ds.state CheckBox1->Checked;
    
cds.dwData 0;
    
cds.cbData sizeof(ds);
    
cds.lpData = &ds;
    
ShowWindow(hReceptSW_SHOW);
    
SetForegroundWindow(hRecept);
    
SendMessage(hReceptWM_COPYDATA0, (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(TWMCopyDatamsg);

protected:
  
BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER
(WM_COPYDATATWMCopyDataOnWMCopyData)
  
END_MESSAGE_MAP(TForm)

public:
  
__fastcall TfrmReceiver(TComponentOwner);
}; 
code
Código PHP:
struct data_struct {
  
char className[255];
  
char caption[255];
  
int xy;
  
TColor color;
  
bool state;
ds;

void __fastcall TfrmReceiver::OnWMCopyData(TWMCopyDatamsg)
{
  
memcpy(&dsmsg.CopyDataStruct->lpDatasizeof(data_struct));

  for(
int i 0ComponentCounti++) {
    
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