500分送上解决问题的一个人,其余入者100分
热门软件下载:
问题如下,对我来说,因为涉及到树视图控件和文件的合并操作,有些为难
但可能对你比较简单。因此请帮帮我:
1。动态添加文件到树视图的相应类别中,并同时存储文件。
2。双击树视图中的文件时打开文件。
3。程序关闭时序列化树视图的内容,程序启动时读入。
我用的是mdi界面,类似vc的界面。其它部分都已完成,但这个问题没有解决
请给出具体的实现或例程,不胜感激;
如果分不够您吱声,另开帖送上。万望帮忙,胜造七级浮屠。
系统限制分数吗?那我就想法捐给你吧。
推荐阅读
我这有树序列化的代码
要的话,发短信,留下 email
up
我以前做过这样list控件的序列化,说到底也就是基于一个递归循环来存储list中的内容!
请问一下,你所指的文件是什么类型的文件?
序列化的实现如下:
to serialize the tree view control override the serialize() function. the serialize() function is a virtual function defined in cobject.
in the code below we save the outline to a text file and can read it back from a text file. when saving the outline to the archive, tabs are used to indent the item text. again, when reading back, tabs are used to determine the level that the newly read item should be placed at.
void ctreectrlx::serialize(carchive& ar)
{
if (ar.isstoring())
{
// storing code
htreeitem hti = getrootitem();
while( hti )
{
int indent = getindentlevel( hti );
while( indent-- )
ar.writestring( "\t" );
ar.writestring( getitemtext( hti ) + "\r\n");
hti = getnextitem( hti );
}
}
else
{
// loading code
cstring sline;
if( !ar.readstring( sline ) )
return;
htreeitem hti = null;
int indent, baseindent = 0;
while( sline[baseindent] == \t )
baseindent++;
do
{
if( sline.getlength() == 0 )
continue;
for( indent = 0; sline[indent] == \t; indent++ )
; // we dont need a body
sline = sline.right( sline.getlength() - indent );
indent -= baseindent;
htreeitem parent;
int previndent = getindentlevel( hti );
if( indent == previndent)
parent = getparentitem( hti );
else if( indent > previndent )
parent = hti;
else
{
int nlevelsup = previndent - indent;
parent = getparentitem( hti );
while( nlevelsup-- )
parent = getparentitem( parent );
}
hti = insertitem( sline, parent ? parent : tvi_root, tvi_last );
}while( ar.readstring( sline ) );
}
}
int ctreectrlx::getindentlevel( htreeitem hitem )
{
int iindent = 0;
while( (hitem = getparentitem( hitem )) != null )
iindent++;
return iindent;
}
// getnextitem - get next item as if outline was completely expanded
// returns - the item immediately below the reference item
// hitem - the reference item
htreeitem ctreectrlx::getnextitem( htreeitem hitem )
{
htreeitem hti;
if( itemhaschildren( hitem ) )
return getchilditem( hitem ); // return first child
else{
// return next sibling item
// go up the tree to find a parents sibling if needed.
while( (hti = getnextsiblingitem( hitem )) == null ){
if( (hitem = getparentitem( hitem ) ) == null )
return null;
}
}
return hti;
}
up
不太懂,但是想拿点分
up,蹭分来了
to newkey007(无限天空):
感谢支持。我的email: rjb@fsdltd.com
gz
...
up
感觉不是那么难吧?
gz
rt
up
不太懂,但是想拿点分
up
up
俺只是想来跟着学点东西。
入
我做过一个简易的活动目录,
其中很大一部分是关于树结构的序列化的,
想要的话可以给我发email:sagasonme@sina.com
学习中!
对不起,我劝你不要采取上边的路线。
数据和界面的分离才是良好的模式。
树仅仅是用来显示和出发消息的渠道。
树上显示的一切应在一个数据容器类中存储。
序列化仅仅是对应数据容器类的序列化,跟树没关。
这样,你就不需要一颗特殊的树了。
如果么保留树的当前显示状态,下次运行时采用一样的状态,
仅仅需要在数据容器类中针对各个项
添加一个记录是否展开和显示的变量即可。
高!!!
数据和界面的分离...
数据容器类的序列化...
高人,我是来领分的,谢l
我做过类似的界面与存储过程,不过是存在数据库中,可以动态的读入写进多层树结构,是用的深度和广度
up一下
upupupupupupupupupup
学习
up
你的题目好有吸引力,学习。
说得真够专业,看完才知道是要用树视图显示存储的文件,并动态更新。但我还是不太会,学习.
up
不太懂,学习
up & study
upupup
up
学习学习
up
学习接分中
学习接分中
数据结构实际上就是个多杈树,
一般对于使用stl 来说,这种多杈树可以利用list来构建,下面随手写一个小类,
仅仅说明问题,并不完善,可以参考它进行你的工作
#include <list>
using namespace std;
template<class t>
struct multitree
{
t m_data;
void addchild(t data)
{
multitree<t> * p=new multitree<t>;
p->m_data=data;
m_child.push_back(p);
}
list<multitree* > m_child;
};
顶
水平所限,只能up:(
up
学习
xue xi
up
gz
up
目前对我太难了..帮你up
up
up
数据和界面的分离才是良好的模式。
树仅仅是用来显示和出发消息的渠道。
树上显示的一切应在一个数据容器类中存储。
序列化仅仅是对应数据容器类的序列化,跟树没关。
这样,你就不需要一颗特殊的树了。
如果么保留树的当前显示状态,下次运行时采用一样的状态,
仅仅需要在数据容器类中针对各个项
添加一个记录是否展开和显示的变量即可。
能否详细解释一下,谢谢!
关注ing!
up
.
相关评论