[MSPAINT] Move UpdateCanvas's code to newly-defined CCanvasWindow::Update

CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-03-17 07:51:12 +09:00
parent 7361592ede
commit eacf003c81
3 changed files with 17 additions and 17 deletions

View file

@ -13,23 +13,22 @@
/* FUNCTIONS ********************************************************/ /* FUNCTIONS ********************************************************/
void VOID CCanvasWindow::Update(HWND hwndFrom)
UpdateCanvas(HWND hwndFrom)
{ {
CRect tempRect; CRect tempRect;
canvasWindow.GetClientRect(&tempRect); GetClientRect(&tempRect);
CSize sizeScrollBox(tempRect.Width(), tempRect.Height()); CSize sizeScrollBox(tempRect.Width(), tempRect.Height());
CSize sizeZoomed = { Zoomed(imageModel.GetWidth()), Zoomed(imageModel.GetHeight()) }; CSize sizeZoomed = { Zoomed(imageModel.GetWidth()), Zoomed(imageModel.GetHeight()) };
CSize sizeWhole = { sizeZoomed.cx + (GRIP_SIZE * 2), sizeZoomed.cy + (GRIP_SIZE * 2) }; CSize sizeWhole = { sizeZoomed.cx + (GRIP_SIZE * 2), sizeZoomed.cy + (GRIP_SIZE * 2) };
/* show/hide the scrollbars */ /* show/hide the scrollbars */
canvasWindow.ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx); ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx);
canvasWindow.ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy); ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy);
if (sizeScrollBox.cx < sizeWhole.cx || sizeScrollBox.cy < sizeWhole.cy) if (sizeScrollBox.cx < sizeWhole.cx || sizeScrollBox.cy < sizeWhole.cy)
{ {
canvasWindow.GetClientRect(&tempRect); GetClientRect(&tempRect);
sizeScrollBox = CSize(tempRect.Width(), tempRect.Height()); sizeScrollBox = CSize(tempRect.Width(), tempRect.Height());
} }
@ -38,14 +37,14 @@ UpdateCanvas(HWND hwndFrom)
si.nMax = sizeWhole.cx; si.nMax = sizeWhole.cx;
si.nPage = sizeScrollBox.cx; si.nPage = sizeScrollBox.cx;
canvasWindow.SetScrollInfo(SB_HORZ, &si); SetScrollInfo(SB_HORZ, &si);
si.nMax = sizeWhole.cy; si.nMax = sizeWhole.cy;
si.nPage = sizeScrollBox.cy; si.nPage = sizeScrollBox.cy;
canvasWindow.SetScrollInfo(SB_VERT, &si); SetScrollInfo(SB_VERT, &si);
INT dx = -canvasWindow.GetScrollPos(SB_HORZ); INT dx = -GetScrollPos(SB_HORZ);
INT dy = -canvasWindow.GetScrollPos(SB_VERT); INT dy = -GetScrollPos(SB_VERT);
if (sizeboxLeftTop.IsWindow()) if (sizeboxLeftTop.IsWindow())
{ {
@ -81,7 +80,7 @@ LRESULT CCanvasWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
{ {
if (m_hWnd) if (m_hWnd)
{ {
UpdateCanvas(m_hWnd); Update(m_hWnd);
} }
return 0; return 0;
} }
@ -112,7 +111,7 @@ LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
break; break;
} }
SetScrollInfo(SB_HORZ, &si); SetScrollInfo(SB_HORZ, &si);
UpdateCanvas(m_hWnd); Update(m_hWnd);
return 0; return 0;
} }
@ -142,7 +141,7 @@ LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
break; break;
} }
SetScrollInfo(SB_VERT, &si); SetScrollInfo(SB_VERT, &si);
UpdateCanvas(m_hWnd); Update(m_hWnd);
return 0; return 0;
} }

View file

@ -21,11 +21,12 @@ public:
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
END_MSG_MAP() END_MSG_MAP()
VOID Update(HWND hwndFrom);
protected:
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
}; };
void UpdateCanvas(HWND hwndFrom);

View file

@ -54,7 +54,7 @@ LRESULT CImgAreaWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
{ {
if (!IsWindow()) if (!IsWindow())
return 0; return 0;
UpdateCanvas(NULL); canvasWindow.Update(NULL);
return 0; return 0;
} }
@ -346,7 +346,7 @@ LRESULT CImgAreaWindow::OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
LRESULT CImgAreaWindow::OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CImgAreaWindow::OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
UpdateCanvas(NULL); canvasWindow.Update(NULL);
return 0; return 0;
} }