保存ini文件和基本控件的保存函数(序:列表和树的保存)
2006-12-12 09:58
489 查看
1列表的保存和提取:
void DIALOG1::SetListValue(int Cname, CString AppName, CString KeyName, CString FileName)
{
int i;
CString sReceiveBuf[50];
m=m_Listgroundrun.GetCount();
for(i=0;i<=m;i++)
{
CString temp[50],KeyNamep[50];
temp[i].Format("%d",i);
KeyNamep[i]=KeyName+temp[i];
sRexeiveBuf[i]=m_Listgroundrun.GetItemText(i);
WritePrivateProfileString(AppName,KeyNamep[i],sReceiveBuf[i],FileName);
}
}
void DIALOG1::GetListValue(int Cname, CString AppName, CString KeyName, CString lpDefault, DWORD nSize, CString FileName)
{
CString strName,strNamep,str;
SHFILEINFO sfi;
CString t="";
char lpResult[100];
int i,n;
for(i=0;i<=50;i++)
{
strName.Format("DIALOG1list%d", i);
GetPrivateProfileString(AppName,strName,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(0,lpResult);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
2树的保存和提取:
void DIALOG1::SetListValue(int Cname, CString AppName, CString KeyName, CString FileName)
{
int i;
CString sReceiveBuf[50];
m=m_Listgroundrun.GetCount();
HTREEITEM hSel=m_Listgroundrun.GetRootItem();
while(hSel)
{
for(i=0;i<=m;i++)
{
CString temp[50],KeyNamep[50];
temp[i].Format("%d",i);
KeyNamep[i]=KeyName+temp[i];
sReceiveBuf[i]=m_Listgroundrun.GetItemText(hSel);
TreeVisit(m_Listgroundrun, hSel);
WritePrivateProfileString(AppName,KeyNamep[i],sReceiveBuf[i],FileName);
hSel=m_Listgroundrun.GetNextItem(hSel, TVGN_NEXT);
}
}
}
void DIALOG1::TreeVisit(CTreeCtrl& m_Listgroundrun, HTREEITEM hItem)
{
CString sReceiveBufc,KeyNamepp,AppName,FileName;
int i,len;
if (m_Listgroundrun.ItemHasChildren(hItem) && hItem !=0x0)
{
HTREEITEM hChildItem = m_Listgroundrun.GetChildItem(hItem);
while(hChildItem!=NULL)
{
for(i=0;i<=50;i++)
{
KeyNamepp.Format("DIALOG1listchild%d", i);
sReceiveBufc=m_Listgroundrun.GetItemText(hChildItem);
WritePrivateProfileString("DIALOG1",KeyNamepp,sReceiveBufc,filepath);
len=sReceiveBufc.GetLength();
if(len==0)
break;
TreeVisit(m_Listgroundrun, hChildItem); //递归遍历孩子节点
hChildItem = m_Listgroundrun.GetNextItem(hChildItem, TVGN_NEXT);
}
}
}
}
void DIALOG1::GetListValue(int Cname, CString AppName, CString KeyName, CString lpDefault, DWORD nSize, CString FileName)
{
CString strName,strNamep,str;
SHFILEINFO sfi;
CString t="";
CString m="//";
char lpResult[100];
int i,n;
for(i=0;i<=50;i++)
{
strName.Format("DIALOG1list%d", i);
GetPrivateProfileString(AppName,strName,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(lpResult);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
HTREEITEM hSel,m_root;
CString sReceiveBuf[50],strt,strc;
n=m_Listgroundrun.GetCount();
hSel=m_Listgroundrun.GetRootItem();
while(hSel)
{
for(i=0;i<=n;i++)
{
sReceiveBuf[i]=m_Listgroundrun.GetItemText(hSel);
strt=sReceiveBuf[i].Mid(2,1);
if (strt!=m)
{
m_root=hSel;
break;
}
hSel=m_Listgroundrun.GetNextItem(hSel, TVGN_NEXT);
}
break;
}
for(i=0;i<=50;i++)
{
strNamep.Format("DIALOG1listchild%d", i);
GetPrivateProfileString(AppName,strNamep,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(lpResult,m_root);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
}
void DIALOG1::SetListValue(int Cname, CString AppName, CString KeyName, CString FileName)
{
int i;
CString sReceiveBuf[50];
m=m_Listgroundrun.GetCount();
for(i=0;i<=m;i++)
{
CString temp[50],KeyNamep[50];
temp[i].Format("%d",i);
KeyNamep[i]=KeyName+temp[i];
sRexeiveBuf[i]=m_Listgroundrun.GetItemText(i);
WritePrivateProfileString(AppName,KeyNamep[i],sReceiveBuf[i],FileName);
}
}
void DIALOG1::GetListValue(int Cname, CString AppName, CString KeyName, CString lpDefault, DWORD nSize, CString FileName)
{
CString strName,strNamep,str;
SHFILEINFO sfi;
CString t="";
char lpResult[100];
int i,n;
for(i=0;i<=50;i++)
{
strName.Format("DIALOG1list%d", i);
GetPrivateProfileString(AppName,strName,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(0,lpResult);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
2树的保存和提取:
void DIALOG1::SetListValue(int Cname, CString AppName, CString KeyName, CString FileName)
{
int i;
CString sReceiveBuf[50];
m=m_Listgroundrun.GetCount();
HTREEITEM hSel=m_Listgroundrun.GetRootItem();
while(hSel)
{
for(i=0;i<=m;i++)
{
CString temp[50],KeyNamep[50];
temp[i].Format("%d",i);
KeyNamep[i]=KeyName+temp[i];
sReceiveBuf[i]=m_Listgroundrun.GetItemText(hSel);
TreeVisit(m_Listgroundrun, hSel);
WritePrivateProfileString(AppName,KeyNamep[i],sReceiveBuf[i],FileName);
hSel=m_Listgroundrun.GetNextItem(hSel, TVGN_NEXT);
}
}
}
void DIALOG1::TreeVisit(CTreeCtrl& m_Listgroundrun, HTREEITEM hItem)
{
CString sReceiveBufc,KeyNamepp,AppName,FileName;
int i,len;
if (m_Listgroundrun.ItemHasChildren(hItem) && hItem !=0x0)
{
HTREEITEM hChildItem = m_Listgroundrun.GetChildItem(hItem);
while(hChildItem!=NULL)
{
for(i=0;i<=50;i++)
{
KeyNamepp.Format("DIALOG1listchild%d", i);
sReceiveBufc=m_Listgroundrun.GetItemText(hChildItem);
WritePrivateProfileString("DIALOG1",KeyNamepp,sReceiveBufc,filepath);
len=sReceiveBufc.GetLength();
if(len==0)
break;
TreeVisit(m_Listgroundrun, hChildItem); //递归遍历孩子节点
hChildItem = m_Listgroundrun.GetNextItem(hChildItem, TVGN_NEXT);
}
}
}
}
void DIALOG1::GetListValue(int Cname, CString AppName, CString KeyName, CString lpDefault, DWORD nSize, CString FileName)
{
CString strName,strNamep,str;
SHFILEINFO sfi;
CString t="";
CString m="//";
char lpResult[100];
int i,n;
for(i=0;i<=50;i++)
{
strName.Format("DIALOG1list%d", i);
GetPrivateProfileString(AppName,strName,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(lpResult);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
HTREEITEM hSel,m_root;
CString sReceiveBuf[50],strt,strc;
n=m_Listgroundrun.GetCount();
hSel=m_Listgroundrun.GetRootItem();
while(hSel)
{
for(i=0;i<=n;i++)
{
sReceiveBuf[i]=m_Listgroundrun.GetItemText(hSel);
strt=sReceiveBuf[i].Mid(2,1);
if (strt!=m)
{
m_root=hSel;
break;
}
hSel=m_Listgroundrun.GetNextItem(hSel, TVGN_NEXT);
}
break;
}
for(i=0;i<=50;i++)
{
strNamep.Format("DIALOG1listchild%d", i);
GetPrivateProfileString(AppName,strNamep,lpDefault,lpResult,nSize,FileName);
if((lpResult[0]!=t) )
{
m_Listgroundrun.InsertItem(lpResult,m_root);
}
else if(lpResult==NULL || lpResult[0]==t)
break;
}
}
相关文章推荐
- 保存ini文件和基本控件的保存函数
- VB中窗体控件的值自动保存到INI文件中.
- 两种方法将CListCtrl控件中列表中的数据保存到文件中
- VC++ 保存 MFC 列表控件(IDC_LST_Table)中的数据到 TXT 文件
- stdio.h头文件中申明的基本函数
- ijg jpeg 函数库:文件列表
- 《zw版·delphi与halcon系列原创教程》zw版_THImagex控件函数列表
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- 一个WinForm记事本程序(包含主/下拉/弹出菜单/打开文件/保存文件/打印/页面设置/字体/颜色对话框/剪切版操作等等控件用法以及记事本菜单事件/按键事件的具体代码)
- unity 基本函数整理[3_GUI控件+GUILayout界面布局]
- android开发实现列表控件滚动位置精确保存和恢复的方法(推荐)
- Head First Python---------(一)第一章(初识Python__人人都爱列表)、第二章(共享你的代码__函数模块)、第三章(文件与异常__处理错误)
- Delphi编程保存数据到Excel文件(4):使用NativeExcel2控件
- c#读取ini配置文件、将配置数据保存至ini文件
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- 【Python学习日记】函数列表 动态创建函数 文件读取 迭代器
- php.ini配置文件详解(为了安全,禁止一些高风险的函数)
- 从xml文件里获取文字(char型) 到列表控件显示的代码范例
- MATLAB基本操作(七):有关文件路径的几个函数在编程中的作用
- asp 读取文件和保存文件函数代码