Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

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.
Tagged:

Comments

  • 2 Comments sorted by Votes Date Added
  • >>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.