?
Solved

Max/min size allowed in edit box

Posted on 1998-11-09
6
Medium Priority
?
476 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
Independent Software Vendors: 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 40 total points
ID: 1324428
Glad I was able to help!

Phillip
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

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…
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…
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, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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