CodePudding user response:
Sea...CodePudding user response:
Is to create an application, and then there are Form1 and Form2 two forms, how to use the values in the sendmessage method will Form2 passed to Form1, beginners are less likely to be used,CodePudding user response:
Add USES in form1 form2, can call form2CodePudding user response:
A, Form11,
USES uForm2;
2, the event
The begin
Form2. Caption:='ABCDEFG;
end;
CodePudding user response:
Thread passed between can consider to useprocedure SendString (strMSG: string; HTargetWin: HWND);
Var
Data: tagCOPYDATASTRUCT;
Pbufs: PChar;
The begin
GetMem (pbufs, Length (strMSG) + 1);
Try
ZeroMemory (pbufs, Length (strMSG) + 1);
StrPCopy (pbufs, strMSG);
Data. CbData:=Length (strMSG) * 2 + 2;
Data. DwData:=Length (strMSG) * 2 + 2;
GetMem (Data. LpData Data. DwData);
Data. LpData:=pbufs;
SendMessage (hTargetWin, WM_COPYDATA to 0, the Integer (@ Data));
The finally
FreeMem (pbufs);
end;
end;
Send
procedure TFrmMain. WM_CopyData (var MSG: TMessage);
Var
Data: ^ tagCOPYDATASTRUCT;
StrMSG: string;
N, j: Integer;
Group: Tlistgroup;
Listitem: Tlistitem;
The begin
Data:=Pointer (Msg. LParam);
StrMSG=StrPas (PChar (Data. LpData));
end;
Receiving
Probably is this meaning I direct interception of a part of the program, used to put a string from one thread to another thread, for reference only
CodePudding user response:
The original poster is not a thread, can be directly after adding unit, direct assignment,