I would like to make my application 64 Bit compatible. I'm struggling with PostMessage and LPARAM. I send an instance of a class via PostMessage. I wonder if it's correct to cast the value test_data to LPARAM.
Please have a look at the following code:
// Data to send
TMyData=class
Data1: string;
Data2: byte;
Data3: TDateTime;
end;
// send
procedure TTestClass1.PostTestData(AData1: string; AData2: byte; AData3: TDateTime);
var
test_data: TMyData;
begin
test_data:= TMyData.Create;
test_data.Data1:= AData1;
test_data.Data2:= AData2;
test_data.Data3:= AData3;
PostMessage(my_handle,WM_MY_MESSAGE,0,LPARAM(test_data));
end;
// receive
procedure TTestClass2.Message_WM_MY_MESSAGE(var Msg: TMessage);
var
test_data: TMyData;
begin
test_data := TMyData(Msg.LParam); // is this also compatible with 64 Bit?
try
// Do some work
finally
test_data.Free;
end;
end;
Is the code above 64 Bit compatible?