Comment échanger des données entre 2 applications Delphi7 ?
Bonjour à tous,
J' ai 2 appli A et B et je jouhaite que A reçoive un message windows en provenance de B
j'ai donc lu le tutorial sur l'échange de données entre 2 applications et ça ne marche pas.
Voici le code des 2 appli
Application A - Celle qui reçoit le message Windows
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
...
public
procedure DefaultHandler(var WinMSG); override;
end;
var
Form1: TForm1;
WM_MESSAGE_FMS, WM_MESSAGE_FRE: integer;
implementation
{$R *.dfm}
procedure TForm1.DefaultHandler(var WinMSG);
begin
inherited DefaultHandler(WinMSG);
if (TMessage(WinMSG).Msg = WM_MESSAGE_FRE)
then Begin
Label_MSG.Caption := IntToStr(TMessage(WinMSG).WParam);
Label_MSG.Update;
end;
end;
// Création fiche
procedure TMAIN.FormCreate(Sender: TObject);
begin
WM_MESSAGE_FMS := RegisterWindowMessage('WM_MESSAGE_FMS');
WM_MESSAGE_FRE := RegisterWindowMessage('WM_MESSAGE_FRE');
end; |
Application B - Celle qui envoie le message Windows
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
...
public
WM_MESSAGE_FMS, WM_MESSAGE_FRE: integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.pb_MSGClick(Sender: TObject);
var
h: THandle;
begin
h := FindWindow(nil, PChar('Application A'));
if h = 0
then ShowMessage('Le receveur (application A) est inactif')
else Begin
SendMessage(h, WM_MESSAGE_FRE, 121, 0);
end;
end;
// Création fiche
procedure TMAIN.FormCreate(Sender: TObject);
begin
WM_MESSAGE_FMS := RegisterWindowMessage('WM_MESSAGE_FMS');
WM_MESSAGE_FRE := RegisterWindowMessage('WM_MESSAGE_FRE');
end; |
Qu'est ce que je n'ai pas compris ?
Merci d'avance pour vos réponses.
Wilco