In this example:
First, you should know that you want to accept the edit handle of the text. There are many ways to do this. This example uses the simplest method of self-acquisition.
Program1: Prepare a program for Receiving text
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) edit1: tedit; button1: tbutton; procedure button1click (Sender: tobject); Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.button1click (Sender: tobject); begin edit1.text: = inttostr (edit1.handle); end; Procedure transaction (Sender: tobject); begin text: = 'program 1'; button1.caption: = 'display edit1'; end.
Program 2: The program that sends text
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) edit1: tedit; edit2: tedit; button1: tbutton; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.button1click (Sender: tobject); var P: pchar; H: hwnd; begin P: = pchar (edit1.text); H: = hwnd (strtointdef (edit2.text, 0); sendmessage (H, wm_settext, strlen (P), Cardinal (p); end; Procedure tform1.formcreate (Sender: tobject); begin text: = 'program 2 '; button1.caption: = 'send the content in edit1 to the text control indicated by the handle in edit2... '; button1.wordwrap: = true; {if it is a version earlier than Delphi 2009, the button may not support line breaks} end; end.
This is the text to be sent. It is a little effort to receive text from the recipient. For more information, see:
Http://www.cnblogs.com/del/archive/2008/11/15/1334237.html
In addition, to obtain the handle of any window (or control), see:
Http://www.cnblogs.com/del/archive/2008/03/09/1097793.html