本文介绍了示例“虚拟树视图"; C ++ Builder XE-XE7中的IterateSubtree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个示例,说明如何在C ++ Embarcadero Xe1-7中使用虚拟树视图" IterateSubtree .
I need an example how to use "virtual treeview" IterateSubtree in C++ Embarcadero Xe1-7.
我对此代码有疑问:
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)
{
}
编译器给出以下错误:
[bcc32 Error] MyFile.cpp(363): E2034 Cannot convert 'void (_fastcall * (_closure )(TBaseVirtualTree *,TVirtualNode *,void *,bool &))(TBaseVirtualTree *,TVirtualNode *,void *,bool &)' to '_di_TVTGetNodeProc'
推荐答案
非常感谢`
我找到了解决方法
typedef void (*TIterateSubtreeCallBack)(TBaseVirtualTree*, PVirtualNode Node, void *_Data, bool &Abort);
class TMyVTGetNodeProcRef : public TCppInterfacedObject<TVTGetNodeProc>
{
private:
TIterateSubtreeCallBack callback;
public:
TMyVTGetNodeProcRef(TIterateSubtreeCallBack _callback) : callback(_callback) {}
INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
void __fastcall Invoke(TBaseVirtualTree* Sender, TVirtualNode *Node, void *Data, bool &Abort)
{
return callback(Sender, Node, Data, Abort);
}
};
void __fastcall TMyForm::BuSearchClick(TObject *)
{
Node= MyTreeView->IterateSubtree(NULL, new TMyVTGetNodeProcRef(SearchDataId), (void*)&PNodeData, TVirtualNodeStates(), false, false);
}
void TMyForm::SearchDataId(TBaseVirtualTree*Tr, PVirtualNode Node, void *_Data, bool &Abort)
{
put my code ...
}
//---------------------------------------------------------------------------
这篇关于示例“虚拟树视图"; C ++ Builder XE-XE7中的IterateSubtree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!