Solved

wm_copydata how to use it

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

15 Experts available now in Live!

Get 1:1 Help Now