[英]Incompatible Types “LongBool” and “Integer”
我需要编译Inno Media Player 0.03的源代码,并对其进行了修改,以使用Delphi向其添加“光标隐藏”功能。
我成功地将代码添加到源代码中,并尝试重新编译,但是编译器说:
[dcc32错误] MainUnit.pas(154):E2010不兼容的类型:'LongBool'和'Integer'。
这段代码有什么问题?
我添加到INNO MEDIA PLAYER的代码:
const
OATRUE = -1;
procedure TDirectShowPlayer.InitializeVideoWindow(WindowHandle: HWND; var Width,
Height: Integer);
begin
ErrorCheck(FGraphBuilder.QueryInterface(IVideoWindow, FVideoWindow));
ErrorCheck(FVideoWindow.HideCursor(OATRUE)); **<<<ERROR IS HERE<<<**
...
end;
我在FVideoWindow
中的TDirectShowPlayer.InitializeVideoWindow
上调用了IVideoWindow::HideCursor
方法。
OATRUE
常量是System.Shortint
而IVideoWindow.HideCursor
是LongBool
方法。
这些类型不兼容吗?或者我的Delphi版本与我添加的代码不兼容?
在MSDN上, IVideoWindow.HideCursor()
被声明为需要很long
输入,而不是BOOL
,因此在Delphi中不应将其声明为LongBool
,而应将其声明为Longint
。 因此,要么修正声明,要么使用类型转换:
ErrorCheck(FVideoWindow.HideCursor(BOOL(OATRUE)));
根据IVideoWindow::HideCursor
上DirectShow文档,方法签名为:
HRESULT HideCursor(
[in] long HideCursor
);
而Progdigy的Pascal翻译中相应的签名是:
function HideCursor(HideCursor: LongBool): HResult; stdcall;
因此,尽管您的代码绝对符合MS规范,但是您必须以某种方式处理错误的类型声明。 您需要将常量类型转换为声明的类型:
ErrorCheck(FVideoWindow.HideCursor(LongBool(OATRUE)));
注意:只要DirectShow对精确值不敏感,仅将True
传递给HideCursor
也可能有效。 请谨慎使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.