Solved

wm_copydata how to use it

Posted on 2002-03-23
3
1,174 Views
Last Modified: 2012-06-27
hi,

i was wondering what wm_copydata and copydatastruct does can anyone give me an example?

cheers
classic_gaming
0
Comment
Question by:classic_gaming
3 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6891000
Not an example at hand, but it is easy.
The whole data block is copead by Windows from the address space of the sending apllication to the address space of the receiving application.
So all data has to be in a single block of memory and you have to state the length of the data.
This means no Pascal strings among other things.
0
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 6891012
hi,
you use WM_COPYDATA  to send data to another app,for
an example make 2 projects:

put a edit in the first and the following ( listener ) :


  public
    { Public declarations }
    procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMCopyData(var Msg: TWMCopyData);
begin
 Edit1.Text := PChar(Msg.CopyDataStruct^.lpData);
end;



in the second project ( the sender ) put a button and a edit and the following :

procedure TForm1.Button1Click(Sender: TObject);
var
 copydata: TCopyDataStruct;
begin
 with copydata do
  begin
   dwData := 0;
   cbData := Length(Edit1.Text) + 1;
   GetMem(lpData, cbData);
   StrCopy(lpData, PChar(Edit1.Text));
  end;
SendMessage(HWND_BROADCAST,WM_COPYDATA,WPARAM(Form1.Handle),LParam(@copydata));
 FreeMem(copydata.lpData);
end;



clicking the button on app2 will send the edits data to the edit on app 1.
hopefully that is of some use :)

Regards Barry
0
 

Author Comment

by:classic_gaming
ID: 7211067
sorry i kept it so long forgot about it :)

cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now