我有一个编辑文本控件,在.rc中表示如下:
EDITTEXT IDC_EDIT1, 26, 23, 60, 14, ES_RIGHT | ES_MULTILINE | ES_AUTOHSCROLL
我尝试使用以下方法取消限制lext:m_editCtrl.SetLimitText(0);
但它不起作用。如果我从 rc文件中删除“ES_RIGHT
”,则效果很好。
有没有办法取消限制ES_RIGHT
的文字限制?
提前致谢。
答案 0 :(得分:0)
似乎ES_RIGHT
风格与ES_AUTOHSCROLL
不相称。
如果您创建没有ES_RIGHT
样式的编辑控件,并且稍后将其修改为:
GetDlgItem(IDC_EDIT1)->ModifyStyle(0, ES_RIGHT);
答案 1 :(得分:0)
if(m_pEdit != NULL)
{
CString strVal;
//Get text value from the dit control
m_pEdit->GetWindowText(strVal);
//Get parent control
CWnd* pParentHwnd = m_pEdit->GetParent();
CRect ctrlRect;
m_pEdit->GetWindowRect(&ctrlRect);
pParentHwnd->ScreenToClient(&ctrlRect);
DWORD dwStyle = m_pEdit->GetStyle();
DWORD dwExstyle = m_pEdit->GetExStyle();
CFont* pFont = m_pEdit->GetFont();
int nCtrlID = m_pEdit->GetDlgCtrlID();
DWORD dwSelection = m_pEdit->GetSel();
CWnd* pWndPreviousCtrl = m_pEdit->GetNextWindow(GW_HWNDPREV);
m_pEdit->DestroyWindow();
if (dwStyle & ES_MULTILINE)
{
dwStyle &= ~ES_MULTILINE;
}
//Create edit control
BOOL bIsCreated = m_pEdit->CreateEx(dwExstyle, _T("EDIT"), strVal, dwStyle, ctrlRect, pParentHwnd, nCtrlID);
if (bIsCreated)
{
//Set window position to maintain z-order for tab navigation
m_pEdit->SetWindowPos(pWndPreviousCtrl, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
//Restore font
m_pEdit->SetFont(pFont);
//Restore last selection
m_pEdit->SetSel(dwSelection);
if (bHasFocus)
{
m_pEdit->SetFocus();
}
}
}
答案 2 :(得分:-2)
该问题对于ES_MULTILINE是可重现的。从rc中删除多行,它将解决问题。