Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 03.12.10 08:15 
Hi, Delpher,

mit dem folgenden Code übergebe ich an ein zweites Delphi-Programm eine String-Variable:

ausblenden volle Höhe Delphi-Quelltext
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:
procedure TBuchMain.ReadStrVariable(Var msg: TMessage);
var H : THandle;
   cds: TCopyDataStruct;
begin
  cds.dwData := 0;
  cds.cbData := StrLen(PChar(SsTname)) + 1;;
  cds.lpData := PChar(SsTname);  // <= Label30 + TbSchueler.tablename
  H := FindWindow('TPatMatForm'NIL);
  SendMessage(H, WM_COPYDATA, Longint(Application.Handle), Integer(@cds));
end;

// Der korrespondierende Code aus dem zweiten Programm ist:

procedure TPatMatForm.ReadStrVariable;
var H: THandle;
begin
  H := FindWindow('TBuchMain'NIL);
  PostMessage(H, WM_READSTR, 00);
end;

procedure TPatMatForm.ReceiveStrVariable(var msg: TWMCopyData );
var sText  : array[0..256of Char;
begin
  StrLCopy(sText, Msg.CopyDataStruct.lpData, Msg.CopyDataStruct.cbData);
  qFname := sText;
  Label11.Caption := qFname;                           {uses FileCtrl/SysUtils}
  Label11.Caption := MinimizeName(qFname,        //Der abzukürzende Pfadname
                                  Label11.Canvas, //Die Referenz-Zeichenfläche
                                  Label11.Width); //Die maximale Ausgabe-Breite
  Label11.Hint := qFname;
end;


Nun möchte ich noch eine zweite Variable "gleichzeitig" mit übergeben können.
Wie gelingt das?
Vielen Dank für Hilfe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 03.12.10 08:23 
Schreib Dir einen Datenpuffer mit beiden Variablen und übergebe diesen statt der einzelnen Variablen beim Senden der Daten.

Auf der Gegenstelle einfach den Puffer auslesen und die beiden Variablen-Werte auseinanderfrickeln.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 03.12.10 10:52 
Hi, Benny,
danke für deine Idee, hat geklappt!
>Gruß aus Lübeck,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas