Skip to content

Instantly share code, notes, and snippets.

@mmozeiko

mmozeiko/test.c Secret

Created Jan 18, 2017
Embed
What would you like to do?
WM_CHAR test
#include <windows.h>
#include <stdio.h>
static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_CHAR)
{
printf("WM_CHAR %04x\n", (unsigned int)wParam);
return 0;
}
else if (Msg == WM_DESTROY)
{
PostQuitMessage(0);
return 0;
}
return DefWindowProcW(hWnd, Msg, wParam, lParam);
}
int main()
{
WNDCLASSW wc =
{
.lpfnWndProc = WindowProc,
.lpszClassName = L"OMGZCLASS",
};
RegisterClassW(&wc);
HWND wnd = CreateWindowW(
wc.lpszClassName, L"OMGZNAME", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, NULL, NULL);
MSG msg;
while (GetMessageW(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment