How to assign the edit text in a program to the edit of another program? -Reply to "disk _"

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.