Ver Mensaje Individual
  #5  
Antiguo 28-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
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 Gaston.

Vas a necesitar una aplicación que envie el string y otra que lo reciba. Una solución es usar el record TCopyDataStruct (unit Windows) para pasar el dato usando el mensaje WM_COPYDATA.

En el ejecutable receptor puse un TPanel que recibe el valor en su propiedad Caption.
(Tál como en el post anterior, reduje código para simplificar)

Ejecutable Emisor:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, SysUtils, Forms, ExtCtrls, Classes, Messages;

type
  TFrmSender = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    procedure SendString(StrToSend: string);
  public
  end;
var
  FrmSender: TFrmSender;

implementation {$R *.dfm}

procedure TFrmSender.SendString(StrToSend: string);
var
  CopyDStruct: TCopyDataStruct;
  ReceptHnd : THandle;
begin
  with CopyDStruct do
  begin
    dwData := 0;
    cbData := 1 + Length(StrToSend);
    lpData := PChar(StrToSend);
  end;
  {¡OJO ACA! En la línea siguiente, las cadenas enviadas a FindWindow,  
   deben ser iguales al nombre del Form Receptor }
  ReceptHnd := FindWindow(PChar('TFrmRecept'),PChar('FrmRecept')) ;
  if ReceptHnd <> 0 then
    SendMessage(ReceptHnd,WM_COPYDATA,Integer(Handle),Integer(@CopyDStruct));
end;

procedure TFrmSender.FormCreate(Sender: TObject);
begin
  Caption:= 'PRUEBA DE DESPLAZAMIENTO DE TEXTO ';
  Timer1.Interval := 1000 div 5;
end;

procedure TFrmSender.Timer1Timer(Sender: TObject);
var
  txt: string;
begin
  txt:= Self.Caption;
  Caption:= Copy(txt, length(txt), 1) + Copy(txt, 1, length(txt) -1);
  SendString(Caption);
end;
end.

Ejecutable Receptor:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TFrmRecept = class(TForm)
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
  private
   procedure WMCopyData(var Msg : TWMCopyData) ; message WM_COPYDATA;
  public
    { Public declarations }
  end;

var
  FrmRecept: TFrmRecept;

implementation {$R *.dfm}

procedure TFrmRecept.WMCopyData(var Msg: TWMCopyData);
begin
  Panel1.Caption:= Pchar(Msg.CopyDataStruct.lpData)
end;

procedure TFrmRecept.FormCreate(Sender: TObject);
begin
  Panel1.Caption:= '';
end;
end.

Luego ejecuta Project1.exe y Project2.exe para ver el resultado.

Por favor utilizá las etiquetas [code] o [delphi], gracias.


Saludos.

Última edición por ecfisa fecha: 28-08-2010 a las 19:23:49.
Responder Con Cita