Jump to content
Sign in to follow this  


Recommended Posts


I am confused as to how WM_CHAR works. I understand how to use the wParam parameter of it but not the lParam.


This 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.


Edited by chris95219

Share this post

Link to post
Share on other sites


I already found out a "more efficient" way, and it works like a charm.

if (PeekMessage(&this->m_LastMsg, NULL, 0, 0, PM_NOREMOVE)) {

        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;
                case VK_TAB:
                    this->m_String += '\t';
                case VK_RETURN:
                    this->m_String += '\n';
                case VK_BACK:
                    if (this->m_String.length() > 0) {
                        this->m_String.erase(this->m_String.length()-1, this->m_String.length());
                case VK_ESCAPE:
                    //block the escape key
                    if (isascii(key)) {
                        this->m_String += key;
        } else if (this->m_LastMsg.message = WM_KEYUP) {
            this->m_LastKey = 0;
        return BGE_OK;

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...