问个CEdit的问题

marorabbit 2003-10-16 11:00:45
谁知道,不用在对话框模板加入cedit控件,而在程序中动态创建一个CEdit,
创建的时候那个只输入数字的style,怎么在程序设置,多谢了
...全文
66 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
marorabbit 2003-10-17
  • 打赏
  • 举报
回复
哈哈
marorabbit 2003-10-17
  • 打赏
  • 举报
回复
多谢大家了
原来是我的msdn有问题,没有ES_NUMBER,我找了一天,我散分
yintongshun 2003-10-17
  • 打赏
  • 举报
回复
CEdit edit
DWORD dwStyle = ES_NUMBER|WS_CHILD|WS_VISIBLE;
edit.Create(dwStyle, rect, pParentWnd, id);
可设置dwStyle其它的值

m_edit.ModifyStyle(0, 0x00002000);
sxslyy 2003-10-17
  • 打赏
  • 举报
回复
重载CEdit类也行,能做到更灵活.
wuxfBrave 2003-10-17
  • 打赏
  • 举报
回复
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 0.
ES_AUTOVSCROLL Automatically scrolls text up one page when the user presses ENTER on the last line.
ES_CENTER Centers text in a single-line or multiline edit control.
ES_LEFT Left-aligns text in a single-line or multiline edit control.
ES_LOWERCASE Converts all characters to lowercase as they are typed into the edit control.
ES_MULTILINE Designates a multiple-line edit control. (The default is single line.) If 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 ES_AUTOVSCROLL is not given, the edit control shows as many lines as possible and beeps if ENTER is pressed when no more lines can be displayed. If the ES_AUTOHSCROLL style is specified, the multiple-line 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 ENTER. If ES_AUTOHSCROLL is not given, the control automatically wraps words to the beginning of the next line when necessary; a new line is also started if ENTER is pressed. The position of the wordwrap is determined by the window size. If the window size changes, the wordwrap position changes and the text is redisplayed. Multiple-line edit controls can have scroll bars. An edit control with scroll bars processes its own scroll-bar messages. Edit controls without scroll bars scroll as described above and process any scroll messages sent by the parent window.
ES_NOHIDESEL Normally, an edit control hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. Specifying ES_NOHIDESEL deletes this default action.
ES_NUMBER Allows only digits to be entered into the edit control.
ES_OEMCONVERT Text entered in the edit control is converted from the ANSI character set to the OEM character set and then back to ANSI. This ensures proper character conversion when the application calls the AnsiToOem Windows function to convert an ANSI string in the edit control to OEM characters. This style is most useful for edit controls that contain filenames.
ES_PASSWORD Displays all characters as an asterisk (*) as they are typed into the edit control. An application can use the SetPasswordChar member function to change the character that is displayed.
ES_READONLY Prevents the user from entering or editing text in the edit control.
ES_RIGHT Right-aligns text in a single-line or multiline edit control.
ES_UPPERCASE Converts all characters to uppercase as they are typed into the edit control.
ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog box’s default pushbutton. This style has no effect on a single-line edit control.


以上是MSDN中列出来的edit的风格
wuxfBrave 2003-10-17
  • 打赏
  • 举报
回复
CEdit edit
DWORD dwStyle = ES_NUMBER|WS_CHILD|WS_VISIBLE;
edit.Create(dwStyle, rect, pParentWnd, id);
你也可设置dwStyle其它的值
flyelf 2003-10-16
  • 打赏
  • 举报
回复
限制只接收数字:CEdit m_edit;
m_edit.ModifyStyle(0, 0x00002000);

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧