Solved

Max/min size allowed in edit box

Posted on 1998-11-09
6
472 Views
Last Modified: 2013-11-20
How can I set a maximum or minimum length of data to be typed in an edit box of a dialog box?  I have a pop up dialog box on each new document that prompts for player names.  What I'd like to do is set the edit box to accept nothing that is under 1 or over 10 letters long.
0
Comment
Question by:Mephisto
[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
  • 3
6 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1324423
The minimum's a tough one!  There's not a standard way to do this except through some sort of masked edit box.  The maximum's easy though, use SetLimitText.

Phillip

0
 

Author Comment

by:Mephisto
ID: 1324424
How/where do I use the SetLimitText() function?  I'm a beginner and was only able to create the dialog box through trial and error and luck.. And don't know how to use the SetLimitText() function.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1324425
I hope you have used ClassWizard to create your CDialog.  If not, you need to learn how.

If you have, choose your class.  Select the 'Member Variable' tab.  Click on the edit control that you want to limit.  Now add a variable for this class making the name something like 'm_ctlFirstName' and the type will be CEdit.  Then 'OK' out of class wizard.

Now you have a member variable tied to the control through the DDX property area.  To limit your text, override the OnInitDialog once again through the ClassWizard and then click the 'Edit Function' button.  Inside of that function, you will want to do something like:  

m_ctlFirstName.SetLimitText( 10 );

OK?

Phillip
0
Technology Partners: 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!

 

Author Comment

by:Mephisto
ID: 1324426
Sorry to reject again, I just wanted to make sure I could get this question answered.  The problem is that the data from the dialog box needs to be saved as a CString because I later use the variable as a CString for output onto the screen.  Is there a way I can create the variable as a CEdit to limit the text and then convert it to a CString?
0
 

Author Comment

by:Mephisto
ID: 1324427
I figured it out (that you can add 2 variables to each ID, one a CEdit, one a CString)..  Thanks for your time..  slap an answer on here and i'll give you the points...
0
 
LVL 7

Accepted Solution

by:
psdavis earned 10 total points
ID: 1324428
Glad I was able to help!

Phillip
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

690 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