Jeremiah
Is it a dynamic array? If so, the problem is probably that the array
is going out of scope (and therefore being destroyed) in the sender
before the receiver has a chance to look at it.
If the problem is not a dynamic array or string, please show us what
kind of data you're actually passing.
-Steve
"Steve Schafer (TeamB)" wrote:
The array is static and contains integer values.
Jeremiah
> The array is static and contains integer values.
Show us what you're doing. We can't read your mind.
-Steve
On the sending side I have this function that sends the message:
var
ReturnValue: LResult;
cds: CopyDataStruct;
begin
AutoTestArray[0] := 10;
AutoTestArray[1] := 48;
cds.dwData := 0;
cds.cbData := sizeof(@AutoTestArray);
cds.lpData := @AutoTestArray;
UserMessage1 := RegisterWindowMessage('Test1');
Hndle := FindWindow('TfrmAutoTest',nil);
If Hndle > 0 then
begin
ReturnValue := SendMessage(Hndle, wm_CopyData,0,Integer(@cds));
Result := ReturnValue;
end
else
Result := Hndle;
end;
AutoTestArray and Hndle are global variables and are declared as follows:
var
Hndle: THandle;
AutoTestArray: Array [0..1] of integer;
So far on the receiving end I have a function that is receiving data:
procedure TfrmAutoTest.CopyData(var Msg: TWmCopyData);
var
Filename: string;
PArray: pointer;
begin
// extract the filename from the data
PArray:= (Msg.CopyDataStruct.lpData);
filename := PChar(PArray);
ShowMessage('OK:' + filename);
end;
The fact that they do talk is all good and fine. My problem is is that I need to know what type to replace PArray with and what to do to use the lpData pointer to extract the data from the AutoTestArray. Hope this helps!
Jeremiah
PLease don't post in HTML, it is against the newsgroup guidelines and
causes problems for some newsreaders.
> So far on the receiving end I have a function that is receiving data:
>
> procedure TfrmAutoTest.CopyData(var Msg: TWmCopyData);
> var
>
> Filename: string;
> PArray: ^Array [0..1] of Integer;
> begin
> // extract the filename from the data
What filename?
PArray:= Pointer(Msg.CopyDataStruct.lpData);
ShowMessage('OK:' + Format('%d; %d', [pArray^[0], pArray^[1]]));
> end;
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Sorry about the HTML. I switched it over to plaintext. As far as
that filename stuff goes, just ignore it. I was using it to get stuff
running and display data onscreen.
For some reason the code you gave me didn't work. In your declaration
of PArray I get this error:
Identifier expected by 'ARRAY' found
And then with the showmessage line at the spot with the pArray^[0],
pArray^[1] I get these errors:
Array type required
Array type required
I know that this probably isn't done too often, but it shouldn't be this
hard. I think that it may be time to go back to the drawing board.
Try do declare a type explicitely:
Type
TIntArray = array [1..2] of Integer;
PIntArray = ^TIntArray;
Var
pArray : PIntArray;
>I know that this probably isn't done too often, but it shouldn't be this
>hard. I think that it may be time to go back to the drawing board.
I don't know if the things Peter suggested were enough to get you
going, but I want to emphasize that we need to see the _real_ code
that you're using, or else we're going to spend all of our time trying
to correct problems that aren't really there. In the first code
example that you posted, you had the sender trying to send an array of
two integers, and the receiver trying to interpret that array as a
filename, of all things.
That can't work, obviously, and I assume that you know that, so if
you're still having trouble getting things to work, please post the
GENUINE code that you're using so that we can try to diagnose the
problem.
-Steve
Peter's code worked, thanks for the help.