Solved

Max/min size allowed in edit box

Posted on 1998-11-09
6
433 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
move a line in eclipse 3 102
changeXy challenge 13 82
Problem to open Excel file 15 133
Work with App store 7 52
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ā€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

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