CDC修改窗口背景出问题一个通讯程序的界面,用VC++,这样写
是想实现:如果通讯正常,某个CEDIT的背景是绿色,如果通讯异常,背景为红色
现在这个程序跑是能跑,有一个麻烦,如果这个窗口前面叠加了一窗口,关闭这个叠加的窗口後,原先有颜色的地方都是白色。但是文字还在这个部分要怎么改呀? CDC *dc=this->edit_communication_status.GetDC();
dc->SetTextColor(SCS_BLACK);
CString str,s2;
s2="                                                                                               ";
switch(scs_status)
{case const_comm_timeout_error:
str.Format("通讯超时,重试次数=%d",scs_sub_param);
dc->SetBkColor(SCS_RED);
break;
case const_comm_ok:
str.Format("通讯正常");
dc->SetBkColor(SCS_GREEN);
s2+="                       ";
break;
case const_comm_packge_format_error:
str.Format("接收的数据包编码错误,错误=%d",this->scs_sub_param);
char error[100];
this->communcation_protocol_stack.explain_value_error_type_of_packge_format(&error[0]);
str+=error;
dc->SetBkColor(SCS_YELLOW);
break;
case const_comm_undefine_error:
str.Format("未知通讯错误,参数=%d",scs_sub_param);
dc->SetBkColor(SCS_BLUE);
break;
}
        //this->edit_communication_status.SetWindowText(str);
str+=s2;
dc->TextOut(0,0,str);