Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cedit limiting text to fixed characters

Posted on 2001-06-18
11
Medium Priority
?
449 Views
Last Modified: 2013-11-20
Hi

I have a member variable bound to cEdit in class wizard. I am trying to restrict user input to this variable to 90 characters. How do I do it..

Please let me know.

0
Comment
Question by:mjagan
[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
  • 4
  • 3
  • 2
  • +2
11 Comments
 

Author Comment

by:mjagan
ID: 6204336
Actually I wrote a function setlimittext and gave it in OnInitDialog but the program caused debug assertion failure when it encounters the setlimittext line that I included.

I was wondering how could the debug assertion failure happen before it is even evaluating the input in this case it did not reach the input screen.
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 6204900
Go into the classwizard after adding the CEdit.  Add a member variable to the edit box (of type CString).  After you do, you will be able to highlight it and there is a "Maximum Characters" edit box at the bottom that you can insert your 90 or whatever.  If you need to do something a little more custom, you can add a message handler to the EN_CHANGE message of the edit box, but the first method will probably work for you.

Good luck.
0
 
LVL 2

Expert Comment

by:mirec
ID: 6205428
CEdit::SetLimitText
void SetLimitText( UINT nMax );

Parameters

nMax

The new text limit, in bytes.

Remarks

Call this member function to set the text limit for this CEdit object. The text limit is the maximum amount of text, in bytes, that the edit control can accept.

Futher details in MSDN.
BYE,mirec
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Accepted Solution

by:
mjagan earned 80 total points
ID: 6206566
As manshadaka suggested I could not add any member variable to the class wizard. It only allows me to add class and other buttons are diabled.

I added the setlimit function as mirec said after OnInitDialog and it bombs immediately after it enters onInitDialog with assertion failure.

Thanks for the response..
0
 
LVL 2

Expert Comment

by:mirec
ID: 6207135
Send please, the source code of your OnInitDialog().
m.
0
 

Author Comment

by:mjagan
ID: 6207209
CDialog :: DoDataExchange(pDX)
DDX_Control(pDX, IDC_VIEW_INV_TXT, m_sAdjWinMsg);
//}} AFX_DATA_MAP

BOOL mywindata:: OnInitDialog()

{
 int TotalAmt;
 int status
m_sAdjWinMsg.SetLimitText(90);

While running program in debug mode it crashes in setlimittext function and goes to mfc/include/afx2...inl and shows nmax as 90 or whatever bytes I give as parameter to setlimittext funnction

Thanks

0
 
LVL 2

Expert Comment

by:mirec
ID: 6207221

Try initialise base class before:

BOOL mywindata:: OnInitDialog()

{
CDialog::OnInitDialog();

int TotalAmt;
int status
m_sAdjWinMsg.SetLimitText(90);

0
 

Author Comment

by:mjagan
ID: 6207576
I tried and unfortunately it did not work.

Thanks for your response again..
0
 

Expert Comment

by:Loggy_yyj
ID: 6208893
Please check the source control ID, is there exist the same type control with the same ID value in your application?

You can check what cause the assertion fails; checking whether the control member is valid!
0
 

Expert Comment

by:Loggy_yyj
ID: 6208895
Please check the source control ID, is there exist the same type control with the same ID value in your application?

You can check what cause the assertion fails; checking whether the control member is valid!
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490010
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : mnashadka

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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