您能告诉我如何在Windows.pas中声明以下符号用于较新的Delphi版本吗?
我希望我的代码与Delphi 2006兼容,我不只是想写“Integer”或“Pointer”,而是“正确”和官方声明。
请您还告诉我Delphi版本的功能
正式加入? (根据http://qc.embarcadero.com/wc/qcmain.aspx?d=48771,似乎在Delphi 11(2007)中这个问题很活跃,在Delphi 12(2009)中问题得到了解决。
答案 0 :(得分:1)
使用VCL控件(包含TControl
的{{1}}后代)时,您不必使用TCustomForm
API来替换窗口过程;您可以设置SetWindowLongPtr
属性以获得相同的结果。我发布了一个示例here。
答案 1 :(得分:0)
我不知道引入Get / SetWindowLongPtr的确切版本,但Delphi 2006也没有定义。
以下声明均来自Delphi 2006。
WNDPROC可能是Windows.pas中的TFNWndProc:
TFarProc = Pointer;
TFNWndProc = TFarProc;
Classes.pas'StdWndProc的签名在Delphi 2006中看起来像这样:
function StdWndProc(Window: HWND; Message, WParam: Longint;
LParam: Longint): Longint; stdcall; assembler;
MSHTML.pas将LONG_PTR定义为:
LONG_PTR = Integer;
这个定义是Delphi 2006源代码目录中唯一提到的LONG_PTR
。
答案 2 :(得分:0)
GetWindowLongPtr和SetWindowLongPtr都出现在Delphi 2009的Windows单元中(编译器的第12版)。
{$EXTERNALSYM GetWindowLongPtr}
function GetWindowLongPtr(hWnd: HWND; nIndex: Integer): LONG_PTR; stdcall;
{$EXTERNALSYM SetWindowLongPtr}
function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: LONG_PTR): LONG_PTR; stdcall;
API的Ansi和Wide版本也被声明,虽然名称和调用没有区别,并且调用不像许多其他API函数那样被转移,其中MyApiFunction的“朴实”版本被重定向到MyApiFunctionA (在D2009之前)或MyApiFunctionW(D2009 +)功能。如:
function MyApiFunction; external advapi32 name 'MyApiFunctionW';
function MyApiFunctionA; external advapi32 name 'MyApiFunctionA';
function MyApiFunctionW; external advapi32 name 'MyApiFunctionW';
如果D2006没有将它们定义为@Frank Shearer说,并且该问题在QC中针对D2007开放并且关闭版本12(D200(),我猜D2009确实是添加这些声明的版本。< / p>
请注意,如果您使用的Delphi版本未提供Windows API,则可以自行添加声明。和API函数一样,最好知道它们存在哪个Windows版本,这样就不会调用运行程序的平台上不存在的API。