Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

virtualtreeview - example "virtual treeview" IterateSubtree in C++Builder XE-XE7

I need an example how to use "virtual treeview" IterateSubtree in C++ Embarcadero Xe1-7.

I have the problem with this code:

void __fastcall TMyForm::BuSearchClick(TObject *)
{
  MyTreeView->IterateSubtree(NULL, SearchDataSomeId, (void*)&PNodeData, TVirtualNodeStates(), false, false);
}

void __fastcall TMyForm::SearchDataSomeId(TBaseVirtualTree*, PVirtualNode Node, void *Data, bool &Abort)
{
}

The compiler gives the following error:

[bcc32 Error] MyFile.cpp(363): E2034 Cannot convert 'void (_fastcall * (_closure )(TBaseVirtualTree *,TVirtualNode *,void *,bool &))(TBaseVirtualTree *,TVirtualNode *,void *,bool &)' to '_di_TVTGetNodeProc'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're trying to use what Delphi/C++Builder calls a method pointer or __closure. Virtual Treeview expects an anonymous method. See here for more details.

I think that creating an anonymous method in C++Builder involves subclassing from TProc and implementing the Invoke method, but it seems to be very poorly documented.

If subclassing TProc doesn't work or is too hard to figure out, I can think of a couple of options:

  • Hack the Virtual Treeview source to create an IterateSubtree overload taking a method pointer.
  • Ask a new question on Stack Overflow in hopes that someone else knows how to create a Delphi anonymous method in C++Builder.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...