Is there such a thing as in the title? I'm trying to do this in part of converting an API structure, and run into something I haven't encountered before:
PFNReaderTranslatedDispatch = function(var msg: TMsg): BOOL; stdcall;
PFNReaderScroll = function(var prmi: TReaderModeInfo; dx, dy: integer): BOOL; stdcall;
TReaderModeInfo = record
cbSize: DWord;
hWnd: THandle;
fFlags: DWord;
prc: PRect;
pfnScroll: PFNReaderScroll;
fFlags2: PFNReaderTranslatedDispatch;
lParam: DWord;
end;
PReaderModeInfo = ^TReaderModeInfo;
Those who know Delphi will see the obvious problem. How would you work around this?
I think this is the simplest solution:
PFNReaderTranslatedDispatch = function(var msg: TMsg): BOOL; stdcall;
PReaderModeInfo = ^TReaderModeInfo;
PFNReaderScroll = function(prmi: PReaderModeInfo; dx, dy: integer): BOOL; stdcall;
TReaderModeInfo = record
cbSize: DWord;
hWnd: THandle;
fFlags: DWord;
prc: PRect;
pfnScroll: PFNReaderScroll;
fFlags2: PFNReaderTranslatedDispatch;
lParam: DWord;
end;
Indeed, you can clearly reaplce a var
parameter by a (by-value) pointer parameter. And there is no problem declaring PReaderModeInfo
before TReaderModeInfo
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With