This forum is temporaily read-only. All existing discussions remain available for reference. For new questions, bug reports or support requests, please contact us at mail@lmdsupport.com.

Const parameters in TElXTree event functions.

I'm using BCB2010, so I'm not sure if this impacts Delphi users. In TElXTree, the "CanDrag" event has this signatore:-

  TElXCanDragEvent = procedure(Sender: TObject; const Item: TElXTreeItem; var CanDrag: Boolean) of object;

The C++ function for this is...

void __fastcall TMainForm::xCanDrag(TObject */*Sender*/,
    const TElXTreeItem *Item, bool &CanDrag)
{
  CanDrag = (Item->Text == "Hello");
}

But, because property access functions like GetText are not const functions, I get the following compiler error:

[BCC32 Error] pdesign.cpp(877): E2522 Non-const function _fastcall TElXTreeItem::GetText() called for const object

Obviously I can use a cast to fix this, but it shouldn't be necessary.

Comments

  • >>so I'm not sure if this impacts Delphi users<<
    No, it does not.

    >>Obviously I can use a cast to fix this, but it shouldn't be necessary.<<
    We'll discuss this. In no case this change would affect Delphi users, because the negative side effect would be. that all existing event handlers would be invalid.

Sign In or Register to comment.