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.
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'.
What is the problem in this code?
The code I added to 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
.
The OATRUE
Constant is a System.Shortint
and IVideoWindow.HideCursor
is a LongBool
method.
Are those incompatible types or is my version of Delphi incompatible with this code that I added ?
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. So either fix the declaration, or use a typecast:
ErrorCheck(FVideoWindow.HideCursor(BOOL(OATRUE)));
According to DirectShow documentation on IVideoWindow::HideCursor
method signature is:
HRESULT HideCursor(
[in] long HideCursor
);
while corresponding signature in Progdigy's Pascal translation is:
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. 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. Use with caution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.