Files
wine-access/tests/foreground_fixture.c

33 lines
1.2 KiB
C

// SPDX-License-Identifier: LGPL-2.1-or-later
#define UNICODE
#define _UNICODE
#include <windows.h>
static HWND button;
static LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wp, LPARAM lp) {
if ((message == WM_SETFOCUS || (message == WM_ACTIVATE && LOWORD(wp) != WA_INACTIVE)) && button)
SetFocus(button);
if (message == WM_DESTROY) { PostQuitMessage(0); return 0; }
return DefWindowProcW(window, message, wp, lp);
}
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show) {
(void)previous; (void)args; (void)show;
WNDCLASSW cls = {0};
cls.hInstance = instance;
cls.lpfnWndProc = window_proc;
cls.lpszClassName = L"WineAccessForegroundFixture";
RegisterClassW(&cls);
HWND launcher = CreateWindowW(cls.lpszClassName, L"Launcher fixture", WS_OVERLAPPEDWINDOW,
50, 50, 300, 200, NULL, NULL, instance, NULL);
button = CreateWindowW(L"Button", L"Play fixture", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
10, 10, 100, 30, launcher, (HMENU)1, instance, NULL);
ShowWindow(launcher, SW_SHOW);
SetForegroundWindow(launcher);
MSG message;
while (GetMessageW(&message, NULL, 0, 0) > 0) {
TranslateMessage(&message);
DispatchMessageW(&message);
}
return 0;
}