Solved

Max/min size allowed in edit box

Posted on 1998-11-09
6
423 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now