2015-02-09 56 views
1

我在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上安裝了更高版本的TVirtualStringTree(版本5.3.0)。同樣的問題仍然存在。如何解決這個TVirtualStringTree Onheaderclick不兼容的參數?

當我建立這個項目在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

您附加的方法vtHeaderClick的參數與OnHeaderClick所需的參數不匹配。由於.dfm文件中定義的屬性是使用RTTI分配的,因此編譯器沒有機會檢查事件處理程序簽名是否正確。只有在運行時纔會發現運行時錯誤,如果幸運的話。

在VTV源中找到OnHeaderClick的聲明,並將所需的簽名與您的方法進行比較。你會看到他們不匹配。您將需要更改vtHeaderClick以匹配。

讓IDE幫助你的一種方法是刪除Object Inspector中的OnHeaderClick的處理程序。然後雙擊OnHeaderClick,IDE將生成一個具有正確簽名的事件處理程序存根。

我不知道什麼是正確的簽名。我可以查看它,但是再一次,你也可以。我試圖用這個答案來告訴你什麼出了問題,並教你如何解決一般問題,而不僅僅是這個具體問題。

+0

非常感謝。你的答案解決了它。 – warren 2015-02-09 09:02:30