在VC ++中的模态框中,消息以蓝色突出显示

时间:2014-10-28 14:30:23

标签: c++ visual-c++ mfc

我们使用下面的代码填充对话框中的消息,当消息出现时,消息以蓝色突出显示 - 就像我们使用鼠标选择消息一样。我希望它出现时不要选择的消息。任何人都可以帮我解决这个问题。

CDialog::OnInitDialog();
CFont *m_pFont = new CFont();
LOGFONT lf;
memset(&lf, 0,sizeof(LOGFONT));
lf.lfHeight = 16;        
lf.lfWeight = FW_BOLD;
strncpy_s(lf.lfFaceName,"Arial",6);
m_pFont->CreateFontIndirectA(&lf);
GetDlgItem(IDC_EDIT1)->SetFont(m_pFont,TRUE);
 m_message.SetWindowTextA((LPCTSTR)Message);  
return TRUE;

1 个答案:

答案 0 :(得分:0)

只要编辑框成为所选项目,选择就会设置为所有文本。如果编辑框是选项卡顺序中的第一个,或者您选中它或单击它,则会选择所有字符。您可以通过捕获EN_SETFOCUS事件并自行重置选择来覆盖此行为:

void CMyDlg::OnEnSetfocusEdit1()
{
   m_edit1.SetSel(0, 0);    // or (-1, -1) to set the selection at the end
}
相关问题