简体   繁体   English

不兼容的类型“ LongBool”和“ Integer”

[英]Incompatible Types “LongBool” and “Integer”

I needed to compile the source code of Inno Media Player 0.03 which was modified by me to add a Cursor Hiding feature to it using Delphi. 我需要编译Inno Media Player 0.03的源代码,并对其进行了修改,以使用Delphi向其添加“光标隐藏”功能。

I added the code to the source successfully and tried to recompile but the compiler says: 我成功地将代码添加到源代码中,并尝试重新编译,但是编译器说:

[dcc32 Error] MainUnit.pas(154): E2010 Incompatible types: 'LongBool' and 'Integer'. [dcc32错误] MainUnit.pas(154):E2010不兼容的类型:'LongBool'和'Integer'。

What is the problem in this code? 这段代码有什么问题?

The code I added to INNO MEDIA PLAYER: 我添加到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;

I called the IVideoWindow::HideCursor method on the FVideoWindow in the TDirectShowPlayer.InitializeVideoWindow . 我在FVideoWindow中的TDirectShowPlayer.InitializeVideoWindow上调用了IVideoWindow::HideCursor方法。

The OATRUE Constant is a System.Shortint and IVideoWindow.HideCursor is a LongBool method. OATRUE常量是System.ShortintIVideoWindow.HideCursorLongBool方法。

Are those incompatible types or is my version of Delphi incompatible with this code that I added ? 这些类型不兼容吗?或者我的Delphi版本与我添加的代码不兼容?

On MSDN, IVideoWindow.HideCursor() is declared as taking a long as input, not a BOOL , so it should not be declared as LongBool in Delphi, it should be Longint instead. 在MSDN上, IVideoWindow.HideCursor()被声明为需要很long输入,而不是BOOL ,因此在Delphi中不应将其声明为LongBool ,而应将其声明为Longint So either fix the declaration, or use a typecast: 因此,要么修正声明,要么使用类型转换:

ErrorCheck(FVideoWindow.HideCursor(BOOL(OATRUE)));

According to DirectShow documentation on IVideoWindow::HideCursor method signature is: 根据IVideoWindow::HideCursor上DirectShow文档,方法签名为:

HRESULT HideCursor(
  [in] long HideCursor
);

while corresponding signature in Progdigy's Pascal translation is: 而Progdigy的Pascal翻译中相应的签名是:

function HideCursor(HideCursor: LongBool): HResult; stdcall;

So, while your code is absolutely complies to MS specification, you have to deal with incorrect type declaration somehow. 因此,尽管您的代码绝对符合MS规范,但是您必须以某种方式处理错误的类型声明。 You need to typecast your constant to declared type: 您需要将常量类型转换为声明的类型:

ErrorCheck(FVideoWindow.HideCursor(LongBool(OATRUE)));

Note: just passing True to HideCursor might also work provided DirectShow isn't sensitive to exact values. 注意:只要DirectShow对精确值不敏感,仅将True传递给HideCursor也可能有效。 Use with caution. 请谨慎使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Delphi:不兼容的类型:&#39;整数&#39;和&#39;扩展&#39; - Delphi: Incompatible types: 'integer' and 'extended' Delphi:“不兼容的整数和扩展类型” - Delphi: “Incompatible types Integer and Extended” 将字符串转换为 VKCode:不兼容的类型:“整数”和“字符串” - Convert string to VKCode: Incompatible types: 'Integer' and 'string' DCC错误…:E2010不兼容的类型:&#39;integer&#39;和&#39;Integer&#39; - DCC Error …: E2010 Incompatible types: 'integer' and 'Integer' 不兼容的类型:“整数”和“过程,无类型的指针或无类型的参数” - Incompatible types: 'Integer' and 'procedure, untyped pointer or untyped parameter' Delphi:不兼容的类型:当两个值都分配为实数时,则为“整数”和“扩展” - Delphi: Incompatible types: 'Integer' and 'Extended' when both values are assigned as real Delphi-E2010不兼容的类型:“整数”和“字符”-任何想法 - Delphi - E2010 Incompatible types: 'Integer' and 'Char' - Any ideas 不兼容的类型:“ TCloseEvent”和“过程” - Incompatible types: 'TCloseEvent' and 'Procedure' IDE编译成功,但dcc32写道:错误:E2010不兼容类型:'Integer'和'NativeInt' - IDE compiles successfully, but dcc32 writes: Error: E2010 Incompatible types: 'Integer' and 'NativeInt' 不兼容的类型:widestring和tintegerfield - incompatible types: widestring and tintegerfield
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM