Solved

wm_copydata how to use it

Posted on 2002-03-23
3
1,192 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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