Created
April 22, 2022 15:36
-
-
Save gofman/befcc1dc8b73d751fac32783f626ea1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
static LRESULT CALLBACK test_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
{ | |
switch (msg) | |
{ | |
case WM_DESTROY: | |
PostQuitMessage(0); | |
break; | |
case WM_GETICON: | |
printf("WM_GETICON wParam %lu.\n", wParam); | |
break; | |
} | |
return DefWindowProcA(hwnd, msg, wParam, lParam); | |
} | |
static HWND hwnd; | |
static DWORD WINAPI thread_proc(void *dummy) | |
{ | |
printf("Thread start.\n"); | |
UpdateLayeredWindow( hwnd, NULL, NULL, NULL, NULL, NULL, 0, NULL, ULW_OPAQUE); | |
printf("Thread done.\n"); | |
return 0; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
WNDCLASSA clsA; | |
HANDLE thread; | |
HICON res; | |
MSG msg; | |
memset(&clsA, 0, sizeof(clsA)); | |
clsA.style = 0; | |
clsA.lpfnWndProc = test_proc; | |
clsA.cbClsExtra = 0; | |
clsA.cbWndExtra = 0; | |
clsA.hInstance = GetModuleHandleA(NULL); | |
clsA.hIcon = 0; | |
clsA.hCursor = 0; | |
clsA.hbrBackground = GetStockObject(WHITE_BRUSH); | |
clsA.lpszMenuName = NULL; | |
clsA.lpszClassName = "test_class"; | |
RegisterClassA(&clsA); | |
hwnd = CreateWindowExA(WS_EX_APPWINDOW | WS_EX_LAYERED, "test_class", | |
"Test", | |
WS_OVERLAPPEDWINDOW, | |
100, 100, 200, 200, | |
NULL, NULL, GetModuleHandleA(NULL), NULL); | |
res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, 0xdeadbeef ); | |
printf("res %p.\n", res); | |
SendMessageA( hwnd, WM_SETICON, ICON_SMALL, 0xdeadbeef ); | |
ShowWindow(hwnd, SW_SHOW); | |
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) | |
DispatchMessage(&msg); | |
thread = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL); | |
if (WaitForSingleObject(thread, 3000) == WAIT_TIMEOUT) | |
puts("Deadlock.\n"); | |
else | |
puts("OK.\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment