[英]How to store zoom of Direct2D window when using WM_MOUSEWHEEL message handling
我正在嘗試使用 Direct2D 輔助函數在鼠標 position 上放大我的ID2D1HwndRenderTarget* renderTarget
窗口。 經過一些測試,我發現GET_WHEEL_DELTA_WPARAM(wParam)
) 為每次鼠標滾輪單擊返回 120(int?short?)。
但現在需要知道如何存儲我的縮放級別。 因為每次我慢慢旋轉鼠標滾輪時,縮放因子將為 1.1 (=1 + 0.1 * 120 / 120),圖像增長 10% 但不會進一步增長。 它應該類似於 zoom = zoom + deltazoom。 但是如何在WindowProc
中存儲變量?
#include <d2d1.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_MOUSEWHEEL:
POINT p = { 0 };
GetCursorPos(&p);
ScreenToClient(hwnd, &p);
renderTarget->SetTransform(
D2D1::Matrix3x2F::Scale(
D2D1::SizeF(
1.0f + 0.1f * GET_WHEEL_DELTA_WPARAM(wParam)/120.0f, // /120.0f to normalize and 0.1 the scale factor
1.0f + 0.1f * GET_WHEEL_DELTA_WPARAM(wParam)/120.0f),
D2D1::Point2F(p.x, p.y)
);
);
return 0;
//
// various other cases
//
}
return DefWindowProc(hwnd, uMsg, wParam, lParam)
}
正如喬納森波特所建議的那樣,解決方案非常簡單,只需將縮放因子添加到包含我的 renderTarget 的renderTarget
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.