Re: Set width of an Cedit control based on required characters
You can use SetLimitText() to set the number of characters in the control...
http://msdn.microsoft.com/en-us/library/c4db48kc(VS.71).aspx
You will have to check any text that is added to the window with
SetWindowText() or UpdateData() before you do it to limit the string since
this only limits user typing.
You can also hook into OnChar and counting the characters that have been
typed as the user goes along. Then you can move to the next control at the
appropriate time. You'll have to allow the user to go back and make changes
(I'd guess) so you'll want to not move it just on the character count, but,
perhaps, when they type the next character after the 70th???
http://msdn.microsoft.com/en-us/library/c4db48kc(VS.71).aspx
Tom
"David Wilkinson" <no-reply@effisols.com> wrote in message
news:uCUdFTtjKHA.1536@TK2MSFTNGP06.phx.gbl...
surjit bawa wrote:
Hello Friends,
Following is my requirement:
I have a dialog with multiline cedit control, I want to set the width of
this cedit control and correspondingly update the width of parent dialog
and the 2 buttons.
e.g I want to allow only 70 characters to be typed in each line of the
cedit control, after user has entered 70 characters cursor should move to
next line. I do not want to use setmargins, only 70 characters should be
visible to the user.
I have already disable horizontal scroll bar.
To get a wrapping CEdit:
Set ES_MULTILINE style
Do not set ES_AUTOHSCROLL style
To determine desired size you can use CDC::GetTextExtent(), and resize in
OnInitDialog().
--
David Wilkinson
Visual C++ MVP