MFC界面状态储存,不要图片格式

xxliu940726 2017-05-27 11:56:14
现在已经将界面设计好了,现在所需要做的就是当我配置好了界面,比如我已经写好了按钮的函数,点击一次按钮,按钮变一次色,再按一次按钮还原。我想把变色的按钮的状态储存起来,当读取的时候按钮的颜色就是变色之后的。再比如combo_box这个空间,选择了第几个选项,保存后再次读取显示的就是第几个选项。现有思路是,每个控件增加标志位来表示其状态,然后储存。当读取的时候,读取标志位,然后遍历所有的函数,根据标志位来更改状态。以达到保存之前的状态。但是这样太繁琐了,有没有简便点的方法?求大牛指导
...全文
374 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdcjk 2017-07-08
  • 打赏
  • 举报
回复
ini 文件里
sichuanwww 2017-07-08
  • 打赏
  • 举报
回复
赵4老师 2017-07-07
  • 打赏
  • 举报
回复
搜“序列化 反序列化”?
gz_qmc 2017-07-06
  • 打赏
  • 举报
回复
自己读写配置文件 或者直接写注册表 那种都可以 关键还是看自己的喜欢
hurryboylqs 2017-07-06
  • 打赏
  • 举报
回复
这个要你自己实现的,比如有很多都不是HWND的,一些自绘的
schlafenhamster 2017-07-06
  • 打赏
  • 举报
回复
例子

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	WINDOWPLACEMENT WndStatus;
	WndStatus.length=sizeof(WINDOWPLACEMENT);
	GetWindowPlacement(&WndStatus);
	theApp.WriteProfileInt("WNDSTATUS","FLAG",WndStatus.flags);
	theApp.WriteProfileInt("WNDSTATUS","SHOWCMD",WndStatus.showCmd);
	theApp.WriteProfileInt("WNDSTATUS","LEFT",WndStatus.rcNormalPosition.left);
	theApp.WriteProfileInt("WNDSTATUS","TOP",WndStatus.rcNormalPosition.top);
	theApp.WriteProfileInt("WNDSTATUS","RIGHT",WndStatus.rcNormalPosition.right);
	theApp.WriteProfileInt("WNDSTATUS","BOTTOM",WndStatus.rcNormalPosition.bottom);
	SaveBarState(theApp.m_pszProfileName);//"HMI_man"
// left tree
	int cxCur;
	int cxMin;//=0
	m_wndSplitter.GetColumnInfo(0,cxCur,cxMin);
	theApp.WriteProfileInt("WNDSTATUS","TREEWIDTH",cxCur);
// if snap dialog still open
	if(m_pSnapDlg) 
	{// still open 
		m_pSnapDlg->CloseFromMain();// delete m_pDIB
		m_pSnapDlg->DestroyWindow();
		if(m_pSnapDlg) delete m_pSnapDlg;
		m_pSnapDlg=NULL;
	}
// save connection type
	SaveConnectionType();
// write com type setting
	CString szStation_INF  = "Station Information";
	CString szEntry_NOW    = "Station Selected";
	CString tmp;
// write station now
	tmp.Format("%d",m_StationNow);
	theApp.WriteProfileString(szStation_INF,szEntry_NOW,tmp);
//
	CFrameWnd::OnClose();
}
/
xinhaoda 2017-05-31
  • 打赏
  • 举报
回复
实际上就是数据存储和读取。只要建立读写关系,其实不是很繁琐。
zgl7903 2017-05-27
  • 打赏
  • 举报
回复
MFC的 UpdateData 和 DoDataExchange 就是用来干这事的
schlafenhamster 2017-05-27
  • 打赏
  • 举报
回复
存 到 。ini 文件里
worldy 2017-05-27
  • 打赏
  • 举报
回复
使用变量对应状态是最合适的,然后保存这个,读取这个变量值进行重建
凌乱哥 2017-05-27
  • 打赏
  • 举报
回复
配置库
oyljerry 2017-05-27
  • 打赏
  • 举报
回复
如果想自己灵活控制,就用变量来处理点击,自己建立映射关系。
xiaohuh421 2017-05-27
  • 打赏
  • 举报
回复
只能用变量保存了.

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧