The compiler error is emitted because the compiler rejects the outermost parens on the left hand side of the final assignment. In essence, your code is akin to the following:
TMyRecord = record
rec1, rec2: TMyRecord;
rec1 := rec2; // compiles
(rec1) := rec2; // E2064 Left side cannot be assigned to
Writing it in this simplified manner brings the issue into very sharp relief.
I'm not sure why the compiler rejects these parens. I suspect that the formal grammar of the language renders your left hand side invalid. Serg provides a plausible explanation in the comments, that is that
(...) is an expression, and an expression is not valid as the left hand side of an assignment. I'm inclined to believe that is accurate.
Anyway, it is simple to fix your code. Instead of
(PMinMaxInfo(Msg.LParam)^) := MinMaxInfo;
PMinMaxInfo(Msg.LParam)^ := MinMaxInfo;
Note that it is not necessary to make a copy of the record, modify it, and then copy it back. You can modify the record directly, once you have cast
LParam to a pointer to the record.
I would do so like this:
procedure TMydlg.WMGetMinMaxInfo(var Msg:TMessage);
pmmi := PMinMaxInfo(Msg.LParam);
pmmi.ptMinTrackSize.X := MinWidth;
pmmi.ptMinTrackSize.Y := MinHeight;
pmmi.ptMaxTrackSize.X := MinWidth;
I've omitted the
^ pointer dereference operator since it is optional in this scenario. If you prefer you might write the assignments like this:
pmmi^.ptMinTrackSize.X := MinWidth;
pmmi^.ptMinTrackSize.Y := MinHeight;
pmmi^.ptMaxTrackSize.X := MinWidth;