如何cedit设置字体大小CEdit的ES

CEdit文本居中_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
文档贡献者
评价文档:
CEdit文本居中
实​现​C​E​d​i​t​文​本​居​中​很​好​的​文​章
大小:2.78KB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢一个已经存在的CEdit控件怎样动态改变它的文字对齐方式,如从左对齐改为右对齐?
主  题:
一个已经存在的CEdit控件怎样动态改变它的文字对齐方式,如从左对齐改为右对齐?
一个已经存在的CEdit控件怎样动态改变它的文字对齐方式,如从左对齐改为右对齐
tonybaobao(Tony宝宝)
) 信誉:100
<font color="#03-10-19 12:27:30Z
得分:<font color="#
m_edit.ModifyStyle(ES_LEFT,ES_RIGHT);//CEdit m_edit
tonybaobao(Tony宝宝)
) 信誉:100
<font color="#03-10-19 12:28:53Z
得分:<font color="#
ES_AUTOHSCROLL
Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to position zero.
ES_AUTOVSCROLL
Automatically scrolls text up one page when the user presses the ENTER key on the last line.
Windows 98/Me, Windows 2000/XP: Centers text in a single-line or multiline edit control.
Windows 95, Windows NT 4.0 and earlier: Centers text in a multiline edit control.
Left aligns text.
ES_LOWERCASE
Converts all characters to lowercase as they are typed into the edit control.
To change this style after the control has been created, use SetWindowLong.
ES_MULTILINE
Designates a multiline edit control. The default is single-line edit control.
When the multiline edit control is in a dialog box, the default response to pressing the ENTER key is to activate the default button. To use the ENTER key as a carriage return, use the ES_WANTRETURN style.
When the multiline edit control is not in a dialog box and the ES_AUTOVSCROLL style is specified, the edit control shows as many lines as possible and scrolls vertically when the user presses the ENTER key. If you do not specify ES_AUTOVSCROLL, the edit control shows as many lines as possible and beeps if the user presses the ENTER key when no more lines can be displayed.
If you specify the ES_AUTOHSCROLL style, the multiline edit control automatically scrolls horizontally when the caret goes past the right edge of the control. To start a new line, the user must press the ENTER key. If you do not specify ES_AUTOHSCROLL, the control automatically wraps words to the beginning of the next line when necessary. A new line is also started if the user presses the ENTER key. The window size determines the position of the Wordwrap. If the window size changes, the Wordwrapping position changes and the text is redisplayed.
Multiline edit controls can have scroll bars. An edit control with scroll bars processes its own scroll bar messages. Note that edit controls without scroll bars scroll as described in the previous paragraphs and process any scroll messages sent by the parent window.
ES_NOHIDESEL
Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.
Allows only digits to be entered into the edit control. Note that, even with this set, it is still possible to paste non-digits into the edit control.
To change this style after the control has been created, use SetWindowLong.
ES_OEMCONVERT
Converts text entered in the edit control. The text is converted from the Windows character set to the OEM character set and then back to the Windows character set. This ensures proper character conversion when the application calls the CharToOem function to convert a Windows string in the edit control to OEM characters. This style is most useful for edit controls that contain file names.
To change this style after the control has been created, use SetWindowLong.
ES_PASSWORD
Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls.
Windows XP: If the edit control is from user32.dll, the default password character is an asterisk. However, if the edit control is from comctl32.dll version 6, the default character is a black circle.
To change the characters that is displayed, or set or clear this style, use the EM_SETPASSWORDCHAR message.
Comctl32.dll version 6 is not redistributable but it is included in Microsoft Windows XP or later. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Using Windows XP Visual Styles.
ES_READONLY
Prevents the user from typing or editing text in the edit control.
To change this style after the control has been created, use the EM_SETREADONLY message.
Windows 98/Me, Windows 2000/XP: Right aligns text in a single-line or multiline edit control. Windows 95, Windows NT 4.0 and earlier: Right aligns text in a multiline edit control.
ES_UPPERCASE
Converts all characters to uppercase as they are typed into the edit control.
To change this style after the control has been created, use SetWindowLong.
ES_WANTRETURN
Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.
To change this style after the control has been created, use SetWindowLong.
ripyu(抢分的恶狼)
) 信誉:78
<font color="#03-10-19 12:29:28Z
得分:<font color="#
ModifyStyle
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 08:57:11Z
得分:<font color="#
我试了,用这个函数只能在编辑框Create之前使用才起作用,当CEdit对象存在时调用ModifyStyle函数不起作用
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 09:40:47Z
得分:<font color="#
能不能这样做?
我想你是通过按下某个按钮来改变对齐方式的吧?
那就在处理这个按钮函数的时候把现在的这个编辑框删除,再用ModifyStyle(),再重新Create()。这样做的话,就要把旧窗口的内容,位置,大小等信息保存下来。
我觉得这个办法蛮笨的,但是应该能用。
或者你在直接调用ModifyStyle()后是否刷新了?再调用Invalidate()试试看。
zhang_dq(虾米)
) 信誉:99
<font color="#03-10-20 09:48:27Z
得分:<font color="#
属性里有设置!
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 13:50:43Z
得分:<font color="#
已经测试过
void CDialogDlg::OnButton1()
// TODO: Add your control notification handler code here
m_edit.ModifyStyleEx(WS_EX_LEFT,WS_EX_RIGHT);
m_edit.Invalidate();
再调用Invalidate()就可以了。
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 13:57:06Z
得分:<font color="#
bigflyingpig(非典型大飞猪):
但是我测试怎么就不行呢?请问m_edit在对话框中的风格时怎么设置的?
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 14:42:43Z
得分:<font color="#
把你的这段代码贴上来看看
m_edit一开始设置Align test为Left
其他没什么改变
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 14:58:01Z
得分:<font color="#
void CDlgTestEdit::OnButtonRight()
// TODO: Add your control notification handler code here
// m_cedit.ModifyStyleEx(WS_EX_LEFT,WS_EX_RIGHT);
// m_cedit.Invalidate();
CEdit *pedit = (CEdit *)GetDlgItem(IDC_EDIT_TEST);
pedit-&ModifyStyleEx(WS_EX_LEFT,WS_EX_RIGHT);
pedit-&Invalidate();
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 15:05:12Z
得分:<font color="#
同样的代码我的可以实现啊
把你的邮箱给我,我把程序打包了发给你
Paris_Luo(不懂)
) 信誉:91
<font color="#03-10-20 15:56:30Z
得分:<font color="#
m_cedit.ModeifyStyle(ES_LEFT, ES_RIGHT)
) 信誉:100
<font color="#03-10-20 16:21:10Z
得分:<font color="#
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 16:41:50Z
得分:<font color="#
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 16:57:37Z
得分:<font color="#
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 17:08:51Z
得分:<font color="#
在我这里还是不行
我的操作系统
win2000 perfeshional
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-20 17:15:12Z
得分:<font color="#
那我不知道原因了
你拿去其他机器上看看呢?
hlijiang(东风)
) 信誉:98
<font color="#03-10-20 17:32:22Z
得分:<font color="#
bigflyingpig(非典型大飞猪)
XP 上是可以的
可能是由于mfc的动态连接库的原因
tonybaobao(Tony宝宝)
) 信誉:100
<font color="#03-10-20 18:21:53Z
得分:<font color="#
可能有这种情况,你修改后,点击一下Edit,就变了。
jiajie828(xiabing)
) 信誉:96
<font color="#03-10-20 18:59:08Z
得分:<font color="#
不懂.W2K下真不行!
dzqsuper(数风流人物-还看打倒日本猪的人)
) 信誉:105
<font color="#03-10-20 19:51:39Z
得分:<font color="#
还没有解决吗
按照上面应该说可以的
我还是邦你顶一下吧
bigflyingpig(非典型大飞猪)
) 信誉:99
<font color="#03-10-21 09:36:38Z
得分:<font color="#
总之是应该是修改以后刷新
就比如重新点一下Edit框
你试试其他的刷新方法。如何让CEdit控件 既设置了ES_AUTOHSCROLL风格,同时又禁止他自动滚动
[问题点数:100分,无满意结帖,结帖人xianglitian]
如何让CEdit控件 既设置了ES_AUTOHSCROLL风格,同时又禁止他自动滚动
[问题点数:100分,无满意结帖,结帖人xianglitian]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2009年 总版技术专家分年内排行榜第四
2009年2月 总版技术专家分月排行榜第一2009年1月 总版技术专家分月排行榜第一2008年11月 总版技术专家分月排行榜第一2008年10月 总版技术专家分月排行榜第一2008年9月 总版技术专家分月排行榜第一2008年8月 总版技术专家分月排行榜第一2008年7月 总版技术专家分月排行榜第一2008年6月 总版技术专家分月排行榜第一2008年5月 总版技术专家分月排行榜第一2008年4月 总版技术专家分月排行榜第一
本帖子已过去太久远了,不再提供回复功能。mfc 自己动态常见了控件,现在想判断控件的是否使用了ES_READONLY风格_百度知道
mfc 自己动态常见了控件,现在想判断控件的是否使用了ES_READONLY风格
如题!!!请高手指教,
提问者采纳
这是拖控件绑变量的 你要new CEdit* 也是差不多的void&CMfcdlg2014Dlg::OnButton1()&{//&TODO:&Add&your&control&notification&handler&code&hereLONG&style&=&GetWindowLong(m_edit1.GetSafeHwnd(),&GWL_STYLE);if(style&&&ES_READONLY){MessageBox(&Yes&);}else{MessageBox(&No&);}}void&CMfcdlg2014Dlg::OnButton2()&{//&TODO:&Add&your&control&notification&handler&code&hereLONG&style&=&GetWindowLong(m_edit2.GetSafeHwnd(),&GWL_STYLE);if(style&&&ES_READONLY){MessageBox(&Yes&);}else{MessageBox(&No&);}}
提问者评价
自己用其它方法解决了,谢谢
来自团队:
其他类似问题
为您推荐:
mfc的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 cedit 设置背景颜色 的文章

 

随机推荐