here's a snipplet from winamp's dev.pages + the url.
The Question is:
How would I define the below declared cds structure in Delphi?
WM_COPYDATA messages are sent using
SendMessage() and a COPYDATASTRUCT structure. In C/C++, you can send
these messages by using:
COPYDATASTRUCT cds;
cds.dwData = id;
cds.lpData = (void*)data;
cds.cbData = data_length;
SendMessage(hwndWinamp,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);
can be found at
http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml
Thanks in advance, Jyri
Sender:
procedure TFormSource.Button1Click(Sender: TObject);
var
h : HWND;
s : string;
r : TCopyDataStruct;
begin
h := FindWindow( 'TFormDestination', 'Destination Form' );
if (h <> 0) then
begin
s := Edit1.Text;
r.dwData := 0;
r.cbData := Length( s );
r.lpData := PChar( s );
SendMessage( h, WM_COPYDATA, Handle, Integer(@r) );
end
else
ShowMessage('Window not found');
end;
Receiver:
// in the class declaration
procedure WMCopyData( var Message: TMessage ); message WM_COPYDATA;
// in the implementation
procedure TFormDestination.WMCopyData(var Message: TMessage);
var
p : PCopyDataStruct;
l : Integer;
s : string;
begin
p := PCopyDataStruct( Message.lParam );
if (p <> nil) then
begin
l := p^.cbData;
SetLength( s, (l+1) );
StrLCopy( PChar(s), PChar(p^.lpData), l );
Edit1.Text := s;
end
else
Edit1.Text := 'ERROR';
end;
Hope this helps...
-Howard