Making a EditBox
-
Hi, Ive posted on this board before but in the Visual C++ area. My Question is : In my previous questions, I created a new EditBox Class Called CInitials and changed the OnChar Message to append a '.' after each keypress. The code for that was done like this:
void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //** Validate the entered character if (isalpha(nChar) ) { // ** Convert lower to to UPPER case if ( islower(nCHAR) ) nChar -=32; // ** Call the default windows procedure as // ** the value of the nChar may have been altered DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); // ** Call the default windows procedure // ** again to add the period. nChar = '.'; DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); } // ** If the backspace key is pressed call the // ** base class function twice to remove the period // ** and the letter if ( nChar == VK_BACK ) { CEdit::OnChar(nChar,nRepCnt,nFlags); CEdit::OnChar(nChar,nRepCnt,nFlags); } }
The CInitials Class was derived from the CEdit Class in Visual C++. The question is, can this be done in C#? If yes how? Thanks again ;) Tom -
Hi, Ive posted on this board before but in the Visual C++ area. My Question is : In my previous questions, I created a new EditBox Class Called CInitials and changed the OnChar Message to append a '.' after each keypress. The code for that was done like this:
void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //** Validate the entered character if (isalpha(nChar) ) { // ** Convert lower to to UPPER case if ( islower(nCHAR) ) nChar -=32; // ** Call the default windows procedure as // ** the value of the nChar may have been altered DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); // ** Call the default windows procedure // ** again to add the period. nChar = '.'; DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); } // ** If the backspace key is pressed call the // ** base class function twice to remove the period // ** and the letter if ( nChar == VK_BACK ) { CEdit::OnChar(nChar,nRepCnt,nFlags); CEdit::OnChar(nChar,nRepCnt,nFlags); } }
The CInitials Class was derived from the CEdit Class in Visual C++. The question is, can this be done in C#? If yes how? Thanks again ;) TomPretty much the same way, but instead of the VK enum, you have the Keys enum, so Keys.BackSpace or something like that. The messages are the same ( seeing as it's still a window underneath it all ). Stuff like IsLower is in the Char space, so Char.IsLower(myChar) Christian Graus - Microsoft MVP - C++
-
Pretty much the same way, but instead of the VK enum, you have the Keys enum, so Keys.BackSpace or something like that. The messages are the same ( seeing as it's still a window underneath it all ). Stuff like IsLower is in the Char space, so Char.IsLower(myChar) Christian Graus - Microsoft MVP - C++
-
There's either an OnChar or an OnKeypress, just type public override, and the ide will give you a list to choose from. Christian Graus - Microsoft MVP - C++