给CComboBox添加记忆
2011-12-29 15:40
99 查看
CComboBox m_combo;
CString m_str;
然后定义一个宏定义:
#define SEC_STR "histotry"
接着在你按确定的按钮的点击函数上实现保存起来
UpdateData();
int index=m_combo.FindStringExact(0,m_str);
if(index>=0)
{
m_combo.DeleteString(index);
m_combo.InsertString(0,m_str);
m_combo.SetCurSel(0);
}
else
{
m_combo.InsertString(0,m_str);
}
CWinApp *app=AfxGetApp();
for(int i=0;i<m_combo.GetCount();i++)
{
CString id;
id.Format("%d",i);
CString str;
m_combo.GetLBText(i,str);
app->WriteProfileString(SEC_STR,id,str);
}
然后在你初始化的函数里添加读取功能
CWinApp *app=AfxGetApp();
for(int i=0;i<20;i++)
{
CString str;
str.Format("%d",i);
str=app->GetProfileString(SEC_STR,str,"");
if(!str.IsEmpty())
{
m_combo.AddString(str);
}
else
{
break;
}
}
CString m_str;
然后定义一个宏定义:
#define SEC_STR "histotry"
接着在你按确定的按钮的点击函数上实现保存起来
UpdateData();
int index=m_combo.FindStringExact(0,m_str);
if(index>=0)
{
m_combo.DeleteString(index);
m_combo.InsertString(0,m_str);
m_combo.SetCurSel(0);
}
else
{
m_combo.InsertString(0,m_str);
}
CWinApp *app=AfxGetApp();
for(int i=0;i<m_combo.GetCount();i++)
{
CString id;
id.Format("%d",i);
CString str;
m_combo.GetLBText(i,str);
app->WriteProfileString(SEC_STR,id,str);
}
然后在你初始化的函数里添加读取功能
CWinApp *app=AfxGetApp();
for(int i=0;i<20;i++)
{
CString str;
str.Format("%d",i);
str=app->GetProfileString(SEC_STR,str,"");
if(!str.IsEmpty())
{
m_combo.AddString(str);
}
else
{
break;
}
}
相关文章推荐
- MFC工具条CToolBar添加非按钮控件CComboBox
- MFC工具条CToolBar添加非按钮控件CComboBox
- 开始我的博客行,为我工作添加些色彩和记忆!
- MFC_CComboBox - 添加字符 - 清空字符 - 获得当前字符 - 获得本机磁盘号
- MFC CComboBox 添加字符串显示不正确的解决方法
- 在CComboBox组合框控件中 使用AddString()函数添加下拉列表项
- MFC工具条CToolBar添加非按钮控件CComboBox
- 关于VC6中基于对话框的程序,往Combox 添加一个CComboBox变量,然后程序编译运行,窗口不出现的问题
- CComboBox 添加水平滚动条
- MFC工具条CToolBar添加非按钮控件CComboBox
- MFC---CComboBox控件添加字符串函数InsertString
- ComBox中item的添加与取值方法
- 添加服务的后台启动项
- asp.net中Cookie的添加 读取 修改和删除
- [转载]给你的Blog添加一个访问计数器
- 给jqGrid数据行添加修改和删除操作链接(之一)
- 如何添加一个Application Framework Service(一)(without native code)
- FreeBSD添加硬盘
- 织梦添加和调用自定义字段的方法
- c c++ 中 各种数据类型 取值溢出的时候 的方便记忆方法【2013.10.14小记】