用于记录类型的转发声明 [英] Forward declarations for record types
本文介绍了用于记录类型的转发声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PFNReaderTranslatedDispatch = function (var msg:TMsg):BOOL;标准
PFNReaderScroll = function(var prmi:TReaderModeInfo; dx,dy:integer):BOOL;标准
TReaderModeInfo = record
cbSize:DWord;
hWnd:THandle;
fFlags:DWord;
prc:PRect;
pfnScroll:PFNReaderScroll;
fFlags2:PFNReaderTranslatedDispatch;
lParam:DWord;
结束
PReaderModeInfo = ^ TReaderModeInfo;知道德尔福的人会看到明显的问题。你会如何解决这个问题?解决方案我认为这是最简单的解决方案:
PFNReaderTranslatedDispatch = function(var msg:TMsg):BOOL;标准
PReaderModeInfo = ^ TReaderModeInfo;
PFNReaderScroll = function(prmi:PReaderModeInfo; dx,dy:integer):BOOL;标准
TReaderModeInfo = record
cbSize:DWord;
hWnd:THandle;
fFlags:DWord;
prc:PRect;
pfnScroll:PFNReaderScroll;
fFlags2:PFNReaderTranslatedDispatch;
lParam:DWord;
结束
的确,您可以清楚地重新发布一个 var
参数(by-value)指针参数。并且在 TReaderModeInfo
之前声明 PReaderModeInfo
没有问题。
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
.
这篇关于用于记录类型的转发声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文