Question

When I run my Win32 application the Windows language bar (which is visible in all other applications) disappears after about 5 seconds. It reappears if I quit my application or alt-tab to a different application. If I alt-tab back into my application, it disappears again after five seconds. The switch key doesn't work either.

It seems as if the system somehow has concluded that my application doesn't "support" the language bar.

Is there something I need to do to for the language bar to be enabled? Or something I shouldn't be doing that can cause it to disappear?

The application has a single custom window (where I draw DirectX graphics). I've looked through the arguments to CreateWindow and RegisterClass as well as the window messages that I handle (instead of passing to DefWindowProc) but nothing seems to be directly related to the language bar.

I've only tested this on Windows 7.

[Update]

Here is a minimalistic example. When I compile and run this, the language bar disappears after five seconds:

#include <windows.h>

LRESULT CALLBACK wndproc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
    return DefWindowProcW(hwnd, umsg, wparam, lparam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSW wc;
    wc.style = CS_DBLCLKS;
    wc.lpfnWndProc = wndproc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandle(nullptr);
    wc.hIcon = 0;
    wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
    wc.hbrBackground = 0;
    wc.lpszMenuName = 0;
    wc.lpszClassName = L"main_window";

    ATOM atom = RegisterClassW(&wc);

    DWORD win_style = WS_OVERLAPPEDWINDOW;

    RECT winrect;
    winrect.top = 100; winrect.bottom = 200; winrect.left = 100; winrect.right = 200;
    AdjustWindowRect(&winrect, win_style, false);

    HWND _hwnd = CreateWindowW(L"main_window", L"Application", win_style,
        winrect.left, winrect.top, winrect.right-winrect.left, winrect.bottom - winrect.top,
        0, 0, GetModuleHandle(0), 0);

    SetFocus(_hwnd);
    ShowWindow(_hwnd, SW_SHOW);
    UpdateWindow(_hwnd);

    MSG msg;
    while (true) {
        PeekMessage(&msg, _hwnd, 0, 0, PM_REMOVE);
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;
}
Was it helpful?

Solution

That snippet is filtering messages: it will only process messages addressed to the window you just created, not to any others that your program needs or uses. Check Raymond Chen's "The dangers of filtering window messages" at http://blogs.msdn.com/b/oldnewthing/archive/2005/02/09/369804.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top