A question
-
How can I make a message when the number of charactors in the editbox reaches 3? Thanks!
Handle the EN_CHANGE message sent by the editbox to it's parent window. Send a WM_GETTEXTLENGTH message to the editbox to check how many characters are in it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
-
How can I make a message when the number of charactors in the editbox reaches 3? Thanks!
I think you want to display a message box right? So you can use EN_CHANGE handler for this purpose. And use GetWindowText(...) to count the number of chars in the edit. But this won't prevent the user from furthur inserting any chars in the edit. But you can prevent this by subclassing the edit and handling WM_CHAR message. If the count in less than 3 then fine call the base class handler or else don't call it instead display a message box. This will prevent the user from inserting further chars. Hope this is what you want.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
Handle the EN_CHANGE message sent by the editbox to it's parent window. Send a WM_GETTEXTLENGTH message to the editbox to check how many characters are in it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
PJ Arends wrote:
WM_GETTEXTLENGTH
:cool:
PJ Arends wrote:
A question and An answer
He he funny.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
How can I make a message when the number of charactors in the editbox reaches 3? Thanks!
I'll assume you are using MFC, so if so you just need to write a function on the edit boxes EN_CHANGE event. The code insode the function would be something like this { // m_EditText is the CString that stores the edit text(whatever you called it) if (strlen(m_EditText) > 3) { // Use other message box function and add correct handle if you know it MessageBox(NULL, "My Text is to long", "Message Caption", 0); } } I believe there are functions to get the size directly from the edit box in MFC but I don't like MFC so I tend to avoid it where possible. -- modified at 23:05 Wednesday 4th January, 2006
-
PJ Arends wrote:
WM_GETTEXTLENGTH
:cool:
PJ Arends wrote:
A question and An answer
He he funny.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
Owner drawn wrote:
An answer TO an Answer
Thats funny too.
-Prakash
-
I think you want to display a message box right? So you can use EN_CHANGE handler for this purpose. And use GetWindowText(...) to count the number of chars in the edit. But this won't prevent the user from furthur inserting any chars in the edit. But you can prevent this by subclassing the edit and handling WM_CHAR message. If the count in less than 3 then fine call the base class handler or else don't call it instead display a message box. This will prevent the user from inserting further chars. Hope this is what you want.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
Owner drawn wrote:
But this won't prevent the user from furthur inserting any chars in the edit. But you can prevent this by subclassing the edit and handling WM_CHAR message. If the count in less than 3 then fine call the base class handler or else don't call it instead display a message box. This will prevent the user from inserting further chars.
EM_LIMITTEXT
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
-
Owner drawn wrote:
But this won't prevent the user from furthur inserting any chars in the edit. But you can prevent this by subclassing the edit and handling WM_CHAR message. If the count in less than 3 then fine call the base class handler or else don't call it instead display a message box. This will prevent the user from inserting further chars.
EM_LIMITTEXT
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
PJ Arends wrote:
EM_LIMITTEXT
:cool:
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
Handle the EN_CHANGE message sent by the editbox to it's parent window. Send a WM_GETTEXTLENGTH message to the editbox to check how many characters are in it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
-
I think you want to display a message box right? So you can use EN_CHANGE handler for this purpose. And use GetWindowText(...) to count the number of chars in the edit. But this won't prevent the user from furthur inserting any chars in the edit. But you can prevent this by subclassing the edit and handling WM_CHAR message. If the count in less than 3 then fine call the base class handler or else don't call it instead display a message box. This will prevent the user from inserting further chars. Hope this is what you want.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord