Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CEdit in MFC?

Posted on 2009-07-07
6
Medium Priority
?
482 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
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
alb66 earned 1600 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 45

Assisted Solution

by:AndyAinscow
AndyAinscow earned 400 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift 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 45

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

824 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