缺少接口方法IControl的实现。

时间:2023-02-05 12:32:29

On XE2 it compiles without problems, on XE5 shows up these errors:

在XE2上编译没有问题,在XE5上显示这些错误:

    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetIsFocused
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetEnabled
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetAbsoluteEnabled
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetPopupMenu
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.EnterChildren
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.ExitChildren
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.DoActivate
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.DoDeactivate
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.MouseClick
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetInheritedCursor
    FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.SetAcceptsControls

Whole FMX.HintManager.pas code is here: http://pastebin.com/XSfahpV0

整个FMX.HintManager。pa代码在这里:http://pastebin.com/XSfahpV0

Line 79 is:

79行:

THintItem  = class;

Anyone could help and tell what exactly should be added so it would be possible to compile? If needed, I could provide with TeamViewer session.

任何人都可以帮助并告诉我们应该添加什么,这样就可以编译了?如果需要,我可以提供TeamViewer会话。

Code is made to use Hints in FireMonkey, but seems none is updating it for long. Full source code is taken from Delphipraxis.

代码在FireMonkey中使用了提示,但是似乎没有人更新它很长时间。完整的源代码来自Delphipraxis。

Regards, G

问候,克

1 个解决方案

#1


4  

Well, the compiler tells you what is up. You just have to learn how to decode its error messages. Here is how to do it.

编译器会告诉你发生了什么。您只需学习如何解码它的错误消息。这是如何做到的。

Let's look at the first error:

让我们看看第一个错误:

FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetIsFocused

pas(79): E2291接口方法icontrol . getisfocus的缺失实现

This first of all points to line 79. Which reads:

这首先指向第79行。上面写:

THintItem  = class;

So the issue is with THintItem. Now this is a little confusing because this is a forward declaration. The real issue is discovered further down the unit, but the compiler always points the finger at where it believes the class declaration starts. And that's the forward declaration. So, whenever you encounter an error at a forward declaration, move forward to the actual declaration. Which is:

所以问题出在THintItem身上。这有点令人困惑,因为这是一个forward声明。真正的问题在单元的后面被发现,但是编译器总是指向它认为的类声明开始的地方。这就是前向声明。因此,当您在forward声明中遇到错误时,请转到实际的声明。这是:

THintItem = class(TFmxObject, IControl)

So, that's a class derived from TFmxObject that implements the IControl interface. Now, the error message tells us that the class is missing an implementation of interface method IControl.GetIsFocused. Well, the compiler is of course right. There is no such method. And all the other errors are of the same nature, for all the other missing functions.

这是一个来自TFmxObject的类,它实现了IControl接口。现在,错误消息告诉我们类缺少接口方法icontrol . getisfocus的实现。编译器当然是对的。没有这样的方法。所有其他的错误都具有相同的性质,对于所有其他缺失的函数。

So, to solve the problem you will need to provide implementations of all the methods in IControl. The issue is no doubt that the FMX framework has changed extensively since its initial release with XE2, which was FMX v1, and the release that ships with XE5 which is FMX v3. You need to study and understand the differences in the framework, and port this code from FMX v1 to FMX v3.

因此,要解决这个问题,需要提供IControl中所有方法的实现。毫无疑问,自从FMX框架最初使用XE2(即FMX v1)和使用XE5(即FMX v3)发布以来,FMX框架已经发生了广泛的变化。您需要研究和理解框架中的差异,并将此代码从FMX v1移植到FMX v3。

Having taken a quick look at THintItem, it seems that most of the implementations of the IControl methods are null. For instance:

快速查看了THintItem之后,似乎大多数IControl方法的实现都是空的。例如:

function THintItem.GetAcceptsControls: Boolean;
begin
  Result := False;
end;

function THintItem.GetCursor: TCursor;
begin
  Result := crNone;
end;

function THintItem.GetDesignInteractive: Boolean;
begin
  Result := False;
end;

procedure THintItem.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

procedure THintItem.MouseMove(Shift: TShiftState; X, Y: Single);
begin
end;

procedure THintItem.MouseUp(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

procedure THintItem.MouseWheel(Shift: TShiftState; WheelDelta: Integer;
  var Handled: Boolean);
begin
end;

So, your starter for ten would be to add empty or stub implementations for each of the missing methods. For instance:

因此,您的入门是为每个缺失的方法添加空的或存根的实现。例如:

function THintItem.GetIsFocused: boolean;
begin
  Result := False;
end;

procedure THintItem.MouseClick(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

You should then study the framework a little more closely to work out whether any of the methods need more than these stubs.

然后,您应该更仔细地研究框架,以确定是否有任何方法需要超过这些存根。

#1


4  

Well, the compiler tells you what is up. You just have to learn how to decode its error messages. Here is how to do it.

编译器会告诉你发生了什么。您只需学习如何解码它的错误消息。这是如何做到的。

Let's look at the first error:

让我们看看第一个错误:

FMX.HintManager.pas(79): E2291 Missing implementation of interface method IControl.GetIsFocused

pas(79): E2291接口方法icontrol . getisfocus的缺失实现

This first of all points to line 79. Which reads:

这首先指向第79行。上面写:

THintItem  = class;

So the issue is with THintItem. Now this is a little confusing because this is a forward declaration. The real issue is discovered further down the unit, but the compiler always points the finger at where it believes the class declaration starts. And that's the forward declaration. So, whenever you encounter an error at a forward declaration, move forward to the actual declaration. Which is:

所以问题出在THintItem身上。这有点令人困惑,因为这是一个forward声明。真正的问题在单元的后面被发现,但是编译器总是指向它认为的类声明开始的地方。这就是前向声明。因此,当您在forward声明中遇到错误时,请转到实际的声明。这是:

THintItem = class(TFmxObject, IControl)

So, that's a class derived from TFmxObject that implements the IControl interface. Now, the error message tells us that the class is missing an implementation of interface method IControl.GetIsFocused. Well, the compiler is of course right. There is no such method. And all the other errors are of the same nature, for all the other missing functions.

这是一个来自TFmxObject的类,它实现了IControl接口。现在,错误消息告诉我们类缺少接口方法icontrol . getisfocus的实现。编译器当然是对的。没有这样的方法。所有其他的错误都具有相同的性质,对于所有其他缺失的函数。

So, to solve the problem you will need to provide implementations of all the methods in IControl. The issue is no doubt that the FMX framework has changed extensively since its initial release with XE2, which was FMX v1, and the release that ships with XE5 which is FMX v3. You need to study and understand the differences in the framework, and port this code from FMX v1 to FMX v3.

因此,要解决这个问题,需要提供IControl中所有方法的实现。毫无疑问,自从FMX框架最初使用XE2(即FMX v1)和使用XE5(即FMX v3)发布以来,FMX框架已经发生了广泛的变化。您需要研究和理解框架中的差异,并将此代码从FMX v1移植到FMX v3。

Having taken a quick look at THintItem, it seems that most of the implementations of the IControl methods are null. For instance:

快速查看了THintItem之后,似乎大多数IControl方法的实现都是空的。例如:

function THintItem.GetAcceptsControls: Boolean;
begin
  Result := False;
end;

function THintItem.GetCursor: TCursor;
begin
  Result := crNone;
end;

function THintItem.GetDesignInteractive: Boolean;
begin
  Result := False;
end;

procedure THintItem.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

procedure THintItem.MouseMove(Shift: TShiftState; X, Y: Single);
begin
end;

procedure THintItem.MouseUp(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

procedure THintItem.MouseWheel(Shift: TShiftState; WheelDelta: Integer;
  var Handled: Boolean);
begin
end;

So, your starter for ten would be to add empty or stub implementations for each of the missing methods. For instance:

因此,您的入门是为每个缺失的方法添加空的或存根的实现。例如:

function THintItem.GetIsFocused: boolean;
begin
  Result := False;
end;

procedure THintItem.MouseClick(Button: TMouseButton; Shift: TShiftState;
  X, Y: Single);
begin
end;

You should then study the framework a little more closely to work out whether any of the methods need more than these stubs.

然后,您应该更仔细地研究框架,以确定是否有任何方法需要超过这些存根。