关于两个DIALOG显示问题,请教一下各位大虾,谢谢
我做了一个两天的界面程序,发现当更改一个EDIT1里字体大小时,EDIT2里的字体全部都跟着更改了,之前输入到EDIT2里面的也都改了,怎么办?字体颜色也一样!谢谢各位!
我是用按钮调系统字体颜色来更改的.
详细:
void CChatDialog::OnBnClickedOk()
{
CString str, mes;
CString str1=CTime::GetCurrentTime().Format(_T("%H:%M:%S"));
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
if(str.GetLength()<1)
{
MessageBox(_T("发送消息不能为空"));
return;
}
CEdit *pEditCtrl=(CEdit *)GetDlgItem(IDC_EDIT2);
pEditCtrl->GetWindowText(mes);
mes+=ShowID+_T(" ")+str1+_T("\r\n");
mes+=str+_T("\r\n\r\n");
pEditCtrl->SetWindowText(mes);
pEditCtrl->LineScroll(pEditCtrl->GetLineCount());
GetDlgItem(IDC_EDIT1)->SetWindowText(_T(""));
GetDlgItem(IDC_EDIT1)->SetFocus();
}
void CChatDialog::OnBnClickedButton1()
{
CColorDialog ColorDlg(m_textcolor);
if(ColorDlg.DoModal()==IDOK)
{
m_textcolor = ColorDlg.GetColor();
Invalidate();
}
// TODO: 在此添加控件通知处理程序代码
}
void CChatDialog::OnBnClickedButton2()
{
CFont*tempfont =m_writemsg.GetFont();
LOGFONT logfont;
tempfont->GetLogFont(&logfont);
CFontDialog fontdlg(&logfont);
if(fontdlg.DoModal()==IDOK)
{
m_font.Detach();
LOGFONT temp;
fontdlg.GetCurrentFont(&temp);
m_font.CreateFontIndirectW(&temp);
m_writemsg.SetFont(&m_font);
m_showmsg.SetFont(&m_font);
// TODO: 在此添加控件通知处理程序代码
}
}
HBRUSH CChatDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetTextColor(m_textcolor);
// TODO: 在此更改 DC 的任何属性
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}