Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! The ES_AUTOHSCROLL actually controls the wrap on/off of the edit. By the way,without the WS_HSCROOL style, you also can scroll the edit by pressing the left or right key.
即: m_Edit.SetWindowText("Because ES_AUTOHSCROLL style can not be modified" " after an edit control has been created, We have to" " create a new edit control and destroy the old one!" " The ES_AUTOHSCROLL actually controls the wrap on/off of the edit." " By the way,without the WS_HSCROOL style, you also can scroll the edit" " by pressing the left or right key.");没有 CRLF !
明白了关键是这一句: Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! 看来我的MSDN里面太老了,没有这个说明 把我给郁闷的。要疯了
VS 2010的确实可以。我用的VC6确实不行。 要通过 @schlafenhamster 的方法才行。
还有一点想问你的。这段文字的来源是哪里? Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! The ES_AUTOHSCROLL actually controls the wrap on/off of the edit. By the way,without the WS_HSCROOL style, you also can scroll the edit by pressing the left or right key.
强大。 你给的代码,原来的3D风格给没了,当然可以通过别的方法找回来。但是过程比较崎岖不是太好 根据你的经验和提示,我自己改了一下,实现了,不用销毁原来的,也不用新建一个新的,而且保留原来的3D风格。 代码又短的实现方法。 起作用的就两行就代码: 再次多谢您的经验,给我的帮助void CEditScreenDlg::OnButton1() { // TODO: Add your control notification handler code here CString str = "1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890"; DWORD Style = GetWindowLong(m_edt1.m_hWnd,GWL_STYLE); SetWindowLong(m_edt1.m_hWnd, GWL_STYLE, Style); m_edt1.SetWindowText(str); }
void CAutoScrollEditDlg::OnAuto()
{
// TODO: Add your control notification handler code here
static BOOL done=FALSE;
CRect rcWin;
m_Edit.GetWindowRect(&rcWin);
ScreenToClient(&rcWin);
//
CFont *pfont=m_Edit.GetFont();
//
DWORD Style=GetWindowLong(m_Edit.m_hWnd,GWL_STYLE);
long id=m_Edit.GetDlgCtrlID();
CString txt;
m_Edit.GetWindowText(txt);
//
done = !done;
if(done)
Style |=(ES_AUTOHSCROLL|WS_HSCROLL);
else
Style &=~(ES_AUTOHSCROLL|WS_HSCROLL);
CEdit edit;
edit.Create(Style,rcWin,this,id);
edit.SetFont(pfont);
edit.SetWindowText(txt); m_Edit.DestroyWindow();
m_Edit.Attach(edit.Detach());
m_Edit.MoveWindow(rcWin);
}需要重新创建edit ,这个风格一旦设置就不能再改回来了.
" after an edit control has been created, We have to"
" create a new edit control and destroy the old one!"
" The ES_AUTOHSCROLL actually controls the wrap on/off of the edit."
" By the way,without the WS_HSCROOL style, you also can scroll the edit"
" by pressing the left or right key.");没有 CRLF !
网上的都是这样说的:
AutoVHcroll True //自动滚屏而已
Multiline True //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
VerticleSrcol True//滚动条而已。
“只是自动滚屏,显示了横向滚动条” 不要自动滚屏,没有横向滚动条 才是 “Word break”
即 ;
Style &=~(ES_AUTOHSCROLL|WS_HSCROLL);
Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one!
看来我的MSDN里面太老了,没有这个说明
把我给郁闷的。要疯了
这是我 写 的 !这些 字符串 间是 没有 CRLF 的 ,如果有 ES_AUTOHSCROLL , 就有 滚动条, 他们会 变成 一行 !没有 ES_AUTOHSCROLL 时他们 会 ”自动换行“ 。
要通过 @schlafenhamster 的方法才行。
Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! The ES_AUTOHSCROLL actually controls the wrap on/off of the edit. By the way,without the WS_HSCROOL style, you also can scroll the edit by pressing the left or right key.
强大。
你给的代码,原来的3D风格给没了,当然可以通过别的方法找回来。但是过程比较崎岖不是太好
根据你的经验和提示,我自己改了一下,实现了,不用销毁原来的,也不用新建一个新的,而且保留原来的3D风格。
代码又短的实现方法。
起作用的就两行就代码:
再次多谢您的经验,给我的帮助void CEditScreenDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString str = "1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890";
DWORD Style = GetWindowLong(m_edt1.m_hWnd,GWL_STYLE);
SetWindowLong(m_edt1.m_hWnd, GWL_STYLE, Style);
m_edt1.SetWindowText(str);
}
再进一步:
子类化一下CEdit类,更改一下OnCreate函数:int CColorEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CEdit::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
DWORD Style = GetWindowLong(CEdit::m_hWnd, GWL_STYLE);
SetWindowLong(CEdit::m_hWnd, GWL_STYLE, Style);
return 0;
}
这样就可以,在属性面板里面设这好属性就可以了,类似VS2010了。
“原来的3D风格给没了” 应该 不会, 因为 原来的 style 是 读出 后 改变的 。 有时间 看看。
你给的代码3D风格确实没了,在VC6上验证过的。
3D 是 exstyle , 忘了考虑。
读出 exStyle。
Create 要 改成 CreatEx(exSytle,。
谢谢
(VerticleSrcol True可以不要) 要想回车换行 Want Return True
(VerticleSrcol True可以不要) 要想回车换行 Want Return True
应当是VS的都可以。我用的VC6不行。
网上的都是这样说的:
AutoVHcroll True //自动滚屏而已
Multiline True //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
网上的都是这样说的:
AutoVHcroll True //自动滚屏而已
Multiline True //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
我试验过了,VS确实可以,但VC6就是不行。确实太老了。
网上的都是这样说的:
AutoVHcroll True //自动滚屏而已
Multiline True //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
我试验过了,VS确实可以,但VC6就是不行。确实太老了。用S吧,VC6V过时了
网上的都是这样说的:
AutoVHcroll True //自动滚屏而已
Multiline True //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
我试验过了,VS确实可以,但VC6就是不行。确实太老了。用S吧,VC6V过时了
唉,是的。