求解释

feinushen2 2013-04-01 02:08:42
CHARFORMAT cf;
memset (&cf, '\0', sizeof (CHARFORMAT));
cf.dwMask = CFM_COLOR;

m_RichSample.GetSelectionCharFormat (cf);
CColorDialog cc (cf.crTextColor);
if (cc.DoModal () == IDCANCEL)
return;
cf.dwMask = CFM_COLOR;
cf.dwEffects &= ~CFE_AUTOCOLOR;
cf.crTextColor = cc.GetColor ();
m_RichSample.SetSelectionCharFormat (cf);
m_RichSample.SetFocus ();


以上红色代码是否多余 注释掉也可正常运行,求解释
...全文
81 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2013-04-02
  • 打赏
  • 举报
回复
return;
cf.dwMask = CFM_COLOR;// 我到觉得这句多余
jimette 2013-04-01
  • 打赏
  • 举报
回复
还是加上初始化0 好些 避免出错1
schlafenhamster 2013-04-01
  • 打赏
  • 举报
回复
去掉memset后:与 cf.dwMask 有关的 部分必须 初始化,; cf.dwMask = CFM_COLOR; 还不如全部初始化为 0.
shen_wei 2013-04-01
  • 打赏
  • 举报
回复
dwMask Members containing valid information or attributes to set. This member can be zero, one, or more than one of the following values.
shen_wei 2013-04-01
  • 打赏
  • 举报
回复
dwMask
Members containing valid information or attributes to set. This member can be zero, one, or more than one of the following values.
山伟 2013-04-01
  • 打赏
  • 举报
回复
memset是对CHARFORMAT对象进行初始化,这个是有必要的。 cf.dwMask = CFM_COLOR;是有效信息和属性的设定。 ---------------------------- 如果去掉可能在使用某些你没有赋值的成员时出现乱码或崩溃的可能

15,979

社区成员

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

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