CEdit subclass question
-
I created a new class that derived from CEdit. Here is OnChar function:
void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); }
I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading. -
I created a new class that derived from CEdit. Here is OnChar function:
void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); }
I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.try using PreTranslateMessage() If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond
-
try using PreTranslateMessage() If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond
-
I created a new class that derived from CEdit. Here is OnChar function:
void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); }
I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.nguyenvhn wrote: nChar -= 'a'-'A'; First off you might look at an ascii table before you do some thing this strange. Second I am not even going to calculate what value this will result in. If you where going to convert ascii characters in this manner you would have to do the following:
if( 'a' <= nChar && nChar <= 'z' )
nChar = 'A' + (nChar - 'a');To do it properly you would do the following:
nChar = toupper(nChar);
Ok! I lied I (calculated) tried your equation and it worked (mathmaticaly), but don't do it. INTP
-
I created a new class that derived from CEdit. Here is OnChar function:
void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); }
I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.Perhaps you could just set the
ES_UPPERCASE
style? To change the style after the control has been created, useSetWindowLong()
. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com