Solved

wm_copydata how to use it

Posted on 2002-03-23
3
1,213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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