cppman Posted September 9, 2007 Posted September 9, 2007 (edited) Hello..I am confused as to how WM_CHAR works. I understand how to use the wParam parameter of it but not the lParam.http://msdn2.microsoft.com/en-us/library/ms646276.aspxThis gives a reference to find out the repeat count for the current message.. but doesn't really fully explain it.Anyone know how to get it?I'm trying to setup an input text buffer to allow easy development of custom edit-like GUI controls. Currently just getting the current character and adding it to the buffer doesn't help because the user will undoubtedly hold down the key longer than it takes to loop through the Update procedure a few times. This causes problems in which for example if they press the a key as if they were typing normally, the result would be "aaaaaa...". Does anyone know of a way to prevent this while not blocking the keys from being held down? I would like it to work exactly like a normal edit control.Thanks. Edited September 9, 2007 by chris95219 Miva OS Project
Richard Robertson Posted September 10, 2007 Posted September 10, 2007 The repeat count has to do with how many times it would be repeated on that message. If you get 3 WM_CHAR's with a repeat count of 5, that would be 15 "presses" because of the repeat. This is what I understand of it.
cppman Posted September 10, 2007 Author Posted September 10, 2007 Thanks, I already found out a "more efficient" way, and it works like a charm. if (PeekMessage(&this->m_LastMsg, NULL, 0, 0, PM_NOREMOVE)) { TranslateMessage(&this->m_LastMsg); } if (this->m_LastMsg.message == WM_CHAR) { //The user pressed a key char key = this->m_LastMsg.wParam; if (this->m_LastKey != key) { this->m_LastKey = key; switch(key) { case VK_TAB: this->m_String += '\t'; break; case VK_RETURN: this->m_String += '\n'; break; case VK_BACK: if (this->m_String.length() > 0) { this->m_String.erase(this->m_String.length()-1, this->m_String.length()); } break; case VK_ESCAPE: //block the escape key break; default: if (isascii(key)) { this->m_String += key; } }; } } else if (this->m_LastMsg.message = WM_KEYUP) { this->m_LastKey = 0; } return BGE_OK; Miva OS Project
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now