Solved

CEdit in MFC?

Posted on 2009-07-07
6
468 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
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 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

740 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