Подскажите есть ли какие нибудь оговорки (ограничения) при обмене структурированными сообщениями в х64 проекте (Delphi XE8). Дело в том что код представленный ниже в х86 варианте работает замечательно, а в х64 выдает AV, т.к. на вход обработчика сообщения приходит пустая структура.
Код: unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
const
WM_CHANGE_STATE = WM_USER + 1;
type
CRecord = packed record
iRecord,
iObject,
iState : Integer;
end;
TCurrRecord = packed record
Msg : Cardinal;
WParam : Integer;
LParam : ^CRecord;
Result : LRESULT;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure WMState(var Msg: TCurrRecord); message WM_CHANGE_STATE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
WP: WPARAM;
LP: CRecord;
begin
WP := 0;
LP.iRecord := StrToInt(Edit1.Text);
LP.iObject := StrToInt(Edit3.Text);
LP.iState := StrToInt(Edit5.Text);
SendStructMessage(Application.MainFormHandle,WM_CHANGE_STATE, WP, LP);
end;
procedure TForm1.WMState(var Msg: TCurrRecord);
begin
Edit2.Text := IntToStr(Msg.LParam^.iRecord);
Edit4.Text := IntToStr(Msg.LParam^.iObject);
Edit6.Text := IntToStr(Msg.LParam^.iState);
end;
end.
Код: unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
const
WM_CHANGE_STATE = WM_USER + 1;
type
CRecord = packed record
iRecord,
iObject,
iState : Integer;
end;
TCurrRecord = packed record
Msg : Cardinal;
WParam : Integer;
LParam : ^CRecord;
Result : LRESULT;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure WMState(var Msg: TCurrRecord); message WM_CHANGE_STATE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
WP: WPARAM;
LP: CRecord;
begin
WP := 0;
LP.iRecord := StrToInt(Edit1.Text);
LP.iObject := StrToInt(Edit3.Text);
LP.iState := StrToInt(Edit5.Text);
SendStructMessage(Application.MainFormHandle,WM_CHANGE_STATE, WP, LP);
end;
procedure TForm1.WMState(var Msg: TCurrRecord);
begin
Edit2.Text := IntToStr(Msg.LParam^.iRecord);
Edit4.Text := IntToStr(Msg.LParam^.iObject);
Edit6.Text := IntToStr(Msg.LParam^.iState);
end;
end.