代码之家  ›  专栏  ›  技术社区  ›  warren

如何解决此TVirtualStringTree-Onheadrclick不兼容参数?

  •  1
  • warren  · 技术社区  · 11 年前

    我在Delphi 7.0 Windows XP 2上测试了Mike Lischke的TVirtualStringTree(4.8.7版)。它工作得很好。我在另一台机器(Delphi 7.0 Windows XP 3系统)上安装了相同的TVirtualStringTree(v.4.8.7),并在Windows XP 3上测试了相同的项目。当我单击标题时,它提示一个错误。我从Delphi 7.0 Windows XP 3中删除了TVirtualStringTree(版本4.8.7),并在Windows XP 3上安装了更高版本的TVirtual StringTree。同样的问题仍然存在。

    当我在Windows XP 3上构建项目时,出现以下提示:

    The vtHeaderClick method referenced by vt.Onheaderclick has an incompatible parameter list. Remove the reference?
    

    我单击“否”并运行测试程序。当我单击标题时,它提示“在…处访问冲突”

    并提示以下错误:

    function TVTHeader.HandleMessage(var Message: TMessage): Boolean;
    
    // The header gets here the opportunity to handle certain messages before they reach the tree. This is important
    // because the tree needs to handle various non-client area messages for the header as well as some dragging/tracking
    // events.
    // By returning True the message will not be handled further, otherwise the message is then dispatched
    // to the proper message handlers.
    
    var
      P: TPoint;
      R: TRect;
      I: TColumnIndex;
      OldPosition: Integer;
      HitIndex: TColumnIndex;
      NewCursor: HCURSOR;
      Button: TMouseButton;
      Menu: TPopupMenu;
      IsInHeader,
      IsHSplitterHit,
      IsVSplitterHit: Boolean;
    
      //--------------- local function --------------------------------------------
    
      function HSPlitterHit: Boolean;
    
      var
        NextCol: TColumnIndex;
        ......
        ......
        case Message.Msg of
              WM_LBUTTONUP:
                with TWMLButtonUp(Message) do
                begin
                  if FColumns.FDownIndex > NoColumn then
                    FColumns.HandleClick(Point(XPos, YPos), mbLeft, False, False);
                 if FStates <> [] then   // this line is highlighted
                    FOwner.DoHeaderMouseUp(mbLeft, KeysToShiftState(Keys), XPos, YPos);
                end;
              WM_NCLBUTTONUP:
                with TWMNCLButtonUp(Message) do
                begin
    
        ......
        ......
    

    我如何解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  1
  •   David Heffernan    11 年前

    您附加的方法 vtHeaderClick 具有与所需参数不匹配的参数 OnHeaderClick 。因为.dfm文件中定义的属性是使用RTTI分配的,所以编译器没有机会检查事件处理程序签名是否正确。如果幸运的话,您只能在运行时发现运行时错误。

    查找的声明 OnHeader单击 并将所需签名与方法的签名进行比较。你会发现它们不匹配。然后你需要改变 vtHeader单击 以匹配。

    让IDE帮助您的一种方法是删除 OnHeader单击 在对象检查器中。然后双击 OnHeader单击 IDE将生成具有正确签名的事件处理程序存根。

    我不知道正确的签名是什么。我可以查一下,但再说一遍,你也可以。我试图用这个答案来告诉你出了什么问题,并教你如何解决一般问题,而不仅仅是这个具体问题。