簡體   English   中英

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

[英]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.ShortintIVideoWindow.HideCursorLongBool方法。

這些類型不兼容嗎?或者我的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM