Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch (msg) {
- case WM_POINTERWHEEL: {
- UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
- POINTER_INFO pi;
- if (GetPointerInfo(pointerId, &pi)) {
- int delta = GET_WHEEL_DELTA_WPARAM(wParam);
- std::cout << "WM_POINTERWHEEL: delta=" << delta << std::endl;
- }
- break;
- }
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) {
- const wchar_t CLASS_NAME[] = L"MyPointerWheelWindowClass";
- WNDCLASS wc = {};
- wc.lpfnWndProc = WndProc;
- wc.hInstance = hInstance;
- wc.lpszClassName = CLASS_NAME;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- RegisterClass(&wc);
- HWND hwnd = CreateWindowEx(
- 0,
- CLASS_NAME,
- L"Pointer Wheel Test",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT, 500, 300,
- NULL, NULL, hInstance, NULL
- );
- if (!hwnd) {
- MessageBox(NULL, L"Failed to create window.", L"Error", MB_OK);
- return 0;
- }
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- // Enable pointer input messages (touchpad, stylus, etc.)
- EnableMouseInPointer(TRUE);
- MSG msg = {};
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement