Solved

CEdit in MFC?

Posted on 2009-07-07
6
474 Views
Last Modified: 2013-11-20
Hi all,
I have a dialog, which contains a Edit box. I set the limit text for this edit box is 16. Now I want the first six characters are fixed (I define it  in code for example AAAAAA), and the user can not change it, the 10 characters will be only numbers. Is there any way to do that? Can anyone give me a suggestion?
Thank you very much.
Regards,
0
Comment
Question by:rambovn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
alb66 earned 400 total points
ID: 24794188
If you are a VS2008 user you can use the CMFCMaskedEdit class
http://msdn.microsoft.com/en-us/library/bb982230.aspx

Otherwise you can handle the WM_CHAR message and do all the stuff by hand
http://support.microsoft.com/?scid=kb%3Ben-us%3B92394&x=6&y=13
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
ID: 24794503
Text field (right aligned, caption = AAAAAA) and edit field next to it.  Edit field set to numeric only and 10 char maximum.
0
 
LVL 8

Author Comment

by:rambovn
ID: 24794743
Thank you for all of your help.
Andy: you meant that I create two controls, 1st: text field, and the 2nd is edit field??? But if  I create 2, my dialog looks ugly, because for something like that either there is overlap or there is a small line between them.
abl66: I am using VS2008 but which .h file should I include?

0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
LVL 8

Author Comment

by:rambovn
ID: 24794769
Andy: now I know what you meant, but it looks not so nice. Is there any way just using one edit field?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 24795115
>>Is there any way just using one edit field?
Have a look at the comment from alb66
0
 
LVL 8

Author Comment

by:rambovn
ID: 24801583
thanks again for all of your help. I am now using alb66's way.
0

Featured Post

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question