【问题标题】:Delphi 2009 ShellTreeView/ShellListView FixDelphi 2009 ShellTreeView/ShellListView 修复
【发布时间】:2008-12-31 16:39:22
【问题描述】:

当 Delphi 2009 项目使用 ShellTreeView/ShellListView 在 IDE 索引中的 mainform 上关闭时,会生成越界 (0) 异常。是否有针对 ShellTreeView/ShellListView 的修复,以便消除异常?

【问题讨论】:

    标签: delphi delphi-2009


    【解决方案1】:

    这是我第一次听说这个。如果有什么安慰的话,我可以在这里复制它。

    您应该做的第一件事可能是在 Quality Central 中提交错误报告,并在 Codegear NNTP 新闻组上提问。

    另外,尝试将 TCustomShellListView.GetFolder 更改为下面的代码,看看你是怎么做的。您需要重新构建包 - 并注意 D2009 出于某种原因在 Windows\System32 中安装了此包的第二个副本。我将其重命名为(到目前为止)没有任何不良影响。

    function TCustomShellListView.GetFolder(Index: Integer): TShellFolder;
    begin
      if Index < FFolders.Count then
        Result := TShellFolder(FFolders[Index])
      else
        Result := NIL;
    end;
    

    【讨论】:

    • 我非常同意 - 这应该发布在 QC 中,然后其他人可以在那里投票。
    【解决方案2】:

    到目前为止,没有任何建议可以解决问题...但是如果我从演示项目中删除 ShellListView 组件然后关闭项目,则不会创建异常。我认为问题出在 ShellListView 组件而不是 ShellTreeView。

    问题可能比看起来要大。

    【讨论】:

      【解决方案3】:
      { TCustomShellTreeView }
      ...
        TCustomShellTreeView = class(TCustomTreeView, IShellCommandVerb)
        public
          constructor Create(AOwner: TComponent); override;
          destructor Destroy; override; //$$jp shellctrl.pas 26.08.2007: missing "override"
          procedure Refresh(Node: TTreeNode);
      ...
      
      destructor TCustomShellTreeView.Destroy;
      begin
        //$$jp: ClearItems;
        //$$jp: raises EInvalidOperation and access-violations (shellctrl.pas 26.08.2007)
        FRootFolder.Free;
        inherited;
      end;
      

      【讨论】:

        【解决方案4】:

        问题仅在设计时出现。

        下面是TShellListView 组件应用于ShellCtrls.pas 文件的解决方案:

        destructor TCustomShellListView.Destroy;
        begin
          ClearItems;
          if not (csDesigning in ComponentState) then // Avoid design time error
          FFolders.Free;
          FreeAndNil(FRootFolder);
          inherited;
        end;
        
        procedure TCustomShellListView.DestroyWnd;
        begin
          ClearItems;
        
          // Avoid error in inherited DestroyWnd procedure :
          if csDesigning in ComponentState then
          Items.Count := 0;
          inherited DestroyWnd;
        end;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-05-05
          • 1970-01-01
          • 2010-11-10
          • 2011-07-12
          • 2011-05-28
          • 1970-01-01
          • 2013-09-13
          相关资源
          最近更新 更多