How to add functionality of Enter/Return key in an Edit Control in C++ Win32 API

I know that in Win32 API (no MFC), in an edit control, there's no functionality of enter key. In a standard textbox, when we press the enter key, the cursor jumps to the next line. I want to add that function of the enter key to the edit control.

I tried subclassing and I was able to detect enter key press but how do I jump to the next line?

This is the following subclass :-

LRESULT CALLBACK EditProc
(
    HWND hWnd,
    UINT msg,
    WPARAM wp,
    LPARAM lp,
    UINT_PTR uIdSubclass,
    DWORD_PTR dwRefData
)
{
    switch (msg)
    {
        case WM_CHAR :
        {
            if (wp == VK_RETURN)
            {
               // Add functionality here
            }
            break;
        }
        default :
        {
            return DefSubclassProc (hWnd, msg, wp, lp);
        }
    }

    return 0;
}


Read more here: https://stackoverflow.com/questions/64944148/how-to-add-functionality-of-enter-return-key-in-an-edit-control-in-c-win32-api

Content Attribution

This content was originally published by Hitarth Padaliya at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: