unit PointSelect;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
  ComObj, ActiveX, yj_TLB, StdVcl, esriSystemUI_TLB,esriControls_TLB,esriCarto_TLB;type
  TPointSelect = class(TAutoObject, ICommand, ITool)
  protected
    function Get_Bitmap: OLE_HANDLE; safecall;
    function Get_Caption: WideString; safecall;
    function Get_Category: WideString; safecall;
    function Get_Checked: WordBool; safecall;
    function Get_Enabled: WordBool; safecall;
    function Get_HelpContextID: Integer; safecall;
    function Get_HelpFile: WideString; safecall;
    function Get_Message: WideString; safecall;
    function Get_Name: WideString; safecall;
    function Get_Tooltip: WideString; safecall;
    procedure OnClick; safecall;
    procedure OnCreate(const hook: IDispatch); safecall;
    function Deactivate: WordBool; safecall;
    function Get_Cursor: OLE_HANDLE; safecall;
    function OnContextMenu(x, y: Integer): WordBool; safecall;
    procedure OnDblClick; safecall;
    procedure OnKeyDown(keyCode, shift: Integer); safecall;
    procedure OnKeyUp(keyCode, shift: Integer); safecall;
    procedure OnMouseDown(button, shift, x, y: Integer); safecall;
    procedure OnMouseMove(button, shift, x, y: Integer); safecall;
    procedure OnMouseUp(button, shift, x, y: Integer); safecall;
    procedure Refresh(hdc: OLE_HANDLE); safecall;
  private
    m_hookHelper:IHookHelper;
  end;implementationuses ComServ;function TPointSelect.Get_Bitmap: OLE_HANDLE;
begin
  Result:=0;
end;function TPointSelect.Get_Caption: WideString;
begin
  Result := 'PointSelect';
end;function TPointSelect.Get_Category: WideString;
begin
  Result := 'Delphi Tools';
end;function TPointSelect.Get_Checked: WordBool;
begin
   Result := False;
end;function TPointSelect.Get_Enabled: WordBool;
beginend;function TPointSelect.Get_HelpContextID: Integer;
begin
   Result:=0;
end;function TPointSelect.Get_HelpFile: WideString;
begin
   Result := '';
end;function TPointSelect.Get_Message: WideString;
begin
   Result := 'Click this command to count the number of vowels in all the layers of this map.';
end;function TPointSelect.Get_Name: WideString;
begin
   result:='PointSelectFeature';
end;function TPointSelect.Get_Tooltip: WideString;
begin
   Result:='Select Point  in mapcontrol';
end;procedure TPointSelect.OnClick;
beginend;procedure TPointSelect.OnCreate(const hook: IDispatch);
var
  tempview:Iactiveview;
begin
    try
      m_hookHelper:=createcomobject(CLASS_HookHelper) as IHookHelper;
      m_hookHelper._Set_Hook(hook);
      m_hookHelper.Get_ActiveView(tempview);
      if tempview=nil then
        m_hookHelper:=nil;
    finally
      m_hookHelper:=nil;
      end;end;function TPointSelect.Deactivate: WordBool;
beginend;function TPointSelect.Get_Cursor: OLE_HANDLE;
beginend;function TPointSelect.OnContextMenu(x, y: Integer): WordBool;
beginend;procedure TPointSelect.OnDblClick;
beginend;procedure TPointSelect.OnKeyDown(keyCode, shift: Integer);
beginend;procedure TPointSelect.OnKeyUp(keyCode, shift: Integer);
beginend;procedure TPointSelect.OnMouseDown(button, shift, x, y: Integer);
beginend;procedure TPointSelect.OnMouseMove(button, shift, x, y: Integer);
beginend;procedure TPointSelect.OnMouseUp(button, shift, x, y: Integer);
beginend;procedure TPointSelect.Refresh(hdc: OLE_HANDLE);
beginend;initialization
  TAutoObjectFactory.Create(ComServer, TPointSelect, Class_PointSelect,
    ciMultiInstance, tmApartment);
end.
在进行arcgis二次开发时候,需要编写一个组件,继承自ICommand,ITool,编译的时候提示错误
[Error] PointSelect.pas(37): Declaration of 'Get_Cursor' differs from declaration in interface 'ITool'
[Error] PointSelect.pas(37): Declaration of 'Refresh' differs from declaration in interface 'ITool'
[Error] PointSelect.pas(37): Declaration of 'Get_Bitmap' differs from declaration in interface 'ICommand'
[Fatal Error] yj.dpr(9): Could not compile used unit 'PointSelect.pas'
高手看看是因为什么原因?是因为这三个方法没有实现吗?另外在C#里边可以使用base关键字来调用基类的方法以及变量(比如base.m_enabled = true;),在delphi里边该如何实现呢?

解决方案 »

  1.   

    1. ITool接口中定义的方法跟TPointSelect类中定义的Get_Cursor和Refresh方法参数或返回值不同(函数签名存在差异)
    2. ICommand接口中定义的方法跟TPointSelect类中定义的Get_Bitmap方法参数或返回值不同(函数签名存在差
    异)
    3. TPointSelect实现ITool, ICommand接口方法不对,所以不能通过编译
    4. 调用基类中的方法或变量,可以将方法或变量放到Protected段中供子类继承
       self.m_enabled = true;    //m_enabled是基类中Protected段中定义的变量,使用self来访问
      

  2.   

    1、你的方法的实现和接口的声明不同
    2、base.xxx = inherited xxx