MCPcopy Create free account
hub / github.com/Hashiao/wuwaBackendTool / scrollWindowClientArea

Method scrollWindowClientArea

utils.cpp:435–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435bool Utils::scrollWindowClientArea(HWND hwnd, int x, int y, int delta) {
436
437 //delta > 0(正数): 模拟滚轮向上滚动(通常意味着内容向上移动)。
438 //delta < 0(负数): 模拟滚轮向下滚动(通常意味着内容向下移动)。
439 if (hwnd == nullptr || !IsWindow(hwnd)) {
440 return false;
441 }
442
443 QMutexLocker locker(&m_locker);
444
445 // 将客户区坐标转换为屏幕坐标
446 POINT clientPoint = {x, y};
447 if (!ClientToScreen(hwnd, &clientPoint)) {
448 qWarning() << "Failed to convert client area coordinates to screen coordinates.";
449 return false;
450 }
451
452 // 构造 lParam 和 wParam
453 LPARAM lParam = MAKELPARAM(x, y);
454 WPARAM wParam = MAKEWPARAM(0, delta); // 可选支持修饰键,低位目前保留为 0
455
456 // 发送滚轮滚动消息
457 PostMessage(hwnd, WM_MOUSEWHEEL, wParam, lParam);
458
459 qDebug() << "Simulated mouse wheel scroll at client area coordinates: ("
460 << x << ", " << y << ") with delta: " << delta;
461
462 return true;
463}
464
465
466

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected