Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:17:03+00:00 2026-06-16T04:17:03+00:00

I’m learning Win32 API. I’ve created an empty window and added an Edit box

  • 0

I’m learning Win32 API. I’ve created an empty window and added an Edit box in it to type some text. I can type a text in it, but can’t switch the keyboard language.

Shortcuts like Alt+Shift don’t work. If I click the language icon in the tray, it will pause for a few seconds, then it will open the list finally, but my window will become inactive, so the change won’t affect it.

I can make the language change happen if I do this:

  1. press Alt+Shift (or whatever the combination is)
  2. press Alt, Space

Step 2 will result, as usual, in the popping of the window menu at the left top, but simultaneously the step 1 will become actual too.

I guess, I’m not processing some kind of message, or creating the window wrong, but I can’t find what is it that is wrong. Here is the full code:

#include <windows.h>

// handle of the edit box
HWND testEditBox;

// shows a message
void showMessage( LPSTR message ){
    MessageBox( GetActiveWindow(), message, "", MB_OK );
}

// a simple window procedure
LRESULT CALLBACK windowProc( HWND window, UINT message, WPARAM wparam, LPARAM lparam )
{
    switch( message )
    {
        case WM_CLOSE:
            DestroyWindow( window );
            break;
        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;
        default:
            return DefWindowProc( window, message, wparam, lparam );
    }
    return 0;
}

int WINAPI WinMain( HINSTANCE instance, HINSTANCE prevInstance, LPSTR commandLine, int showMode )
{
    // create window class
    WNDCLASS windowClass;
    windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.style = 0;
    windowClass.hInstance = instance;
    windowClass.hCursor = LoadCursor( NULL, IDC_ARROW );
    windowClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    windowClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    windowClass.lpszClassName = "testWindow";
    windowClass.lpfnWndProc = windowProc;

    if( !RegisterClass( &windowClass ) )
    {
        showMessage( "Some trouble, sir" );
        return GetLastError();
    }

    HWND window = CreateWindow
    (
        "testWindow",
        "Test Window",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        400, 300,
        NULL, // no parent
        NULL, // no menu
        instance,
        NULL // no 'window-creation data'
    );

    if( !window ){
        showMessage( "Some trouble, sir" );
        return GetLastError();
    }

    ShowWindow( window, showMode );


    // add an EDIT box to our window
    testEditBox = CreateWindow
    (
        "EDIT",
        "input here",
        WS_CHILD,
        10, 10,
        200, 20,
        window,
        NULL,
        instance,
        NULL
    );
    ShowWindow( testEditBox, SW_SHOW );

    // start message loop
    MSG message;
    while( GetMessage( &message, window, 0, 0 ) > 0 )
    {
        TranslateMessage( &message );
        DispatchMessage( &message );
    }


    return message.wParam;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:17:04+00:00Added an answer on June 16, 2026 at 4:17 am

    The problem lays in the line GetMessage( &message, window, 0, 0 ). You are receiving messages only for the window, not testEditBox, so some messages aren’t dispatched. The line should be like GetMessage(&message, NULL, 0, 0).

    These are the messages received by testEditBox in your application when I press and release Ctrl + Shift:

    WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0
    WM_KEYDOWN nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:0 fUp:0
    WM_KEYUP nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:1 fUp:1
    WM_KEYUP nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:1 fUp:1
    

    Compare them to the messages after the fix:

    WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0
    WM_KEYDOWN nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:0 fUp:0
    WM_KEYUP nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:1 fUp:1
    WM_IME_NOTIFY dwCommand:IMN_CLOSESTATUSWINDOW dwData:00000000
    WM_IME_NOTIFY dwCommand:IMN_OPENSTATUSWINDOW dwData:00000000
    WM_INPUTLANGCHANGE charset:0 hkl:04090409 //this
    WM_IME_NOTIFY dwCommand:IMN_SETCOMPOSITIONFONT dwData:00000000
    WM_KEYUP nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:1 fUp:1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.