18#define classCResizeDialog classCDialog
99 enum { DEFAULT_LINESTEP = 20 };
133 : _super(), m_originalSize(0, 0), m_lineStep(DEFAULT_LINESTEP)
134 , m_onThemeChanged(false), m_canSizeDisp(true)
146 : _super(lpszTemplateName, pParentWnd), m_originalSize(0, 0), m_lineStep(DEFAULT_LINESTEP)
147 , m_onThemeChanged(false), m_canSizeDisp(true)
159 : _super(nIDTemplate, pParentWnd), m_originalSize(0, 0), m_lineStep(DEFAULT_LINESTEP)
160 , m_onThemeChanged(false), m_canSizeDisp(true)
170 return CPoint(m_horizontalParam.GetPos(), m_verticalParam.GetPos());
182 int cx = m_horizontalParam.GetPos();
183 int cy = m_verticalParam.GetPos();
186 pDc->OffsetWindowOrg(cx, cy);
190 pDc->OffsetWindowOrg(-cx, -cy);
215 return m_originalSize;
227 UINT r = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE;
228 m_canSizeDisp =
false;
229 _super::SetWindowPos(NULL, 0, 0, size.cx, size.cy, r);
230 m_canSizeDisp =
true;
233 m_originalSize = rc.Size();
246 m_originalSize = size;
248 s += m_offsetWinToClient;
249 UINT r = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE;
250 m_canSizeDisp =
false;
251 _super::SetWindowPos(NULL, 0, 0, s.cx, s.cy, r);
252 m_canSizeDisp =
true;
265 if ( m_horizontalParam.GetMax() < size.cx )
267 dx -= size.cx - m_horizontalParam.GetMax();
269 if ( m_verticalParam.GetMax() < size.cy )
271 dy -= size.cy - m_verticalParam.GetMax();
273 m_OnHScroll(SB_LEFT, 0, NULL);
274 m_OnVScroll(SB_TOP, 0, NULL);
275 m_horizontalParam.ShowBar(*
this, SB_HORZ,
false);
276 m_verticalParam.ShowBar(*
this, SB_VERT,
false);
279 m_originalSize = size;
281 s += m_offsetWinToClient;
282 UINT r = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE;
283 _super::SetWindowPos(NULL, 0, 0, s.cx, s.cy, r);
286 _super::ScrollWindow(dx, 0);
287 _super::ScrollWindow(0, dy);
307 m_OnHScroll(SB_LEFT, 0, NULL);
308 m_OnVScroll(SB_TOP, 0, NULL);
311 SetWindowPos(NULL, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_NOZORDER);
329 if ( m_originalSize.cx == 0 )
332 _super::GetClientRect(&cliRc);
334 _super::GetWindowRect(&winRc);
335 m_originalSize = cliRc.Size();
336 m_offsetWinToClient = winRc.Size() - cliRc.Size();
349 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
354 case WM_NCLBUTTONDBLCLK:
355 TTRACE0(
"WM_NCLBUTTONDBLCLK\n");
356 if ( wParam == HTCAPTION )
359 _super::SetWindowPos(NULL, 0, 0, s.cx, s.cy, SWP_NOMOVE | SWP_NOZORDER);
364 TTRACE0(
"WM_SIZE\n");
365 r = _super::WindowProc(message, wParam, lParam);
368 m_OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
371 case WM_GETMINMAXINFO:
372 TTRACE0(
"WM_GETMINMAXINFO\n");
374 if ( m_originalSize.cx != 0 )
376 LPMINMAXINFO P =
reinterpret_cast<LPMINMAXINFO
>(lParam);
377 P->ptMaxTrackSize.x = m_originalSize.cx + m_offsetWinToClient.cx;
378 P->ptMaxTrackSize.y = m_originalSize.cy + m_offsetWinToClient.cy;
382 TTRACE2(
"WM_HSCROLL %d 0x%08X\n", LOWORD(wParam), lParam);
383 m_OnHScroll(LOWORD(wParam), HIWORD(wParam),
reinterpret_cast<HWND
>(lParam));
386 TTRACE2(
"WM_VSCROLL %d 0x%08X\n", LOWORD(wParam), lParam);
387 m_OnVScroll(LOWORD(wParam), HIWORD(wParam),
reinterpret_cast<HWND
>(lParam));
390 TTRACE0(
"WM_MOUSEWHEEL\n");
391 if ( m_OnMouseWheel(LOWORD(wParam),
static_cast<short>(HIWORD(wParam)), lParam) )
397 TTRACE1(
"WM_PRINT 0x%08X\n", lParam);
398 r = _super::WindowProc(message, wParam, lParam & ~(PRF_OWNED | PRF_CHILDREN));
399 if ( (lParam & PRF_CHILDREN) != 0 )
402 _super::GetWindowRect(rectWin);
403 CDC* pDC = CDC::FromHandle(
reinterpret_cast<HDC
>(wParam));
404 CPoint orgOrg = pDC->GetWindowOrg();
405 CWnd* pWnd = CWnd::GetWindow(GW_CHILD);
406 while ( pWnd != NULL )
409 pWnd->GetWindowRect(rect);
410 CSize po = rect.TopLeft() - rectWin.TopLeft();
411 pDC->SetWindowOrg(orgOrg - po);
412 pWnd->SendMessage(WM_PRINT, wParam, lParam | PRF_CHECKVISIBLE);
413 pWnd = pWnd->GetNextWindow();
415 pDC->SetWindowOrg(orgOrg);
416 if ( (lParam & PRF_NONCLIENT) != 0 )
418 SendMessage(message, wParam, PRF_NONCLIENT);
423 TTRACE0(
"WM_PRINTCLIENT\n");
425 CDC* pDC = CDC::FromHandle(
reinterpret_cast<HDC
>(wParam));
432 TTRACE0(
"WM_INITDIALOG\n");
433 r = _super::WindowProc(message, wParam, lParam);
436 case WM_THEMECHANGED:
437 TTRACE0(
"WM_THEMECHANGED\n");
438 m_onThemeChanged =
true;
440 case WM_EXITSIZEMOVE:
441 TTRACE0(
"WM_EXITSIZEMOVE\n");
442 m_onThemeChanged =
false;
444 case WM_WINDOWPOSCHANGED:
445 TTRACE0(
"WM_WINDOWPOSCHANGED\n");
447 LRESULT r = _super::WindowProc(message, wParam, lParam);
448 WINDOWPOS* W =
reinterpret_cast<WINDOWPOS*
>(lParam);
449 if ( m_onThemeChanged && (W->flags & SWP_FRAMECHANGED) != 0 )
452 _super::GetClientRect(&cliRc);
454 _super::GetWindowRect(&winRc);
455 CSize sz = m_offsetWinToClient;
456 m_offsetWinToClient = winRc.Size() - cliRc.Size();
457 if ( m_horizontalParam.IsEnable() )
459 m_offsetWinToClient.cx -= ::GetSystemMetrics(SM_CYHSCROLL);
461 if ( m_verticalParam.IsEnable() )
463 m_offsetWinToClient.cy -= ::GetSystemMetrics(SM_CXHSCROLL);
465 m_OnSize(0, cliRc.right, cliRc.bottom);
471 return _super::WindowProc(message, wParam, lParam);
485 CBarParam(
void) : m_boIsEnable(false), m_pos(0), m_max(0), m_page(0) { }
487 int GetPos(
void)
const {
return m_boIsEnable ? m_pos : 0; }
489 int GetMax(
void)
const {
return m_max; }
491 bool IsEnable(
void)
const {
return m_boIsEnable; }
504 if ( m_pos + m_page > m_max )
506 delta = m_pos - (m_max - m_page);
507 m_pos = m_max - m_page;
512 void ShowBar(HWND h,
int nBar,
bool isEnable)
514 m_boIsEnable = isEnable;
517 SCROLLINFO si = {
sizeof(SCROLLINFO), SIF_ALL, 0, m_max - 1, m_page, m_pos, 0 };
518 ASSERTLIB( si.cbSize ==
sizeof(SCROLLINFO) && si.nPos == m_pos );
519 ::SetScrollInfo(h, nBar, &si, TRUE);
520 ::ShowScrollBar(h, nBar, TRUE);
524 ::ShowScrollBar(h, nBar, FALSE);
529 int Scroll(UINT nSBCode, UINT nPos,
int lineStep)
const
539 if ( m_pos + m_page < m_max )
541 int r = (nSBCode == SB_LINERIGHT) ? lineStep : m_page;
542 delta = min(r, m_max - (m_pos + m_page));
549 int r = (nSBCode == SB_LINELEFT) ? lineStep : m_page;
550 delta = -min(r, m_pos);
554 case SB_THUMBPOSITION:
555 delta =
static_cast<int>(nPos) - m_pos;
560 if ( m_pos + delta < 0 )
564 if ( m_pos + m_page + delta > m_max )
566 delta = m_max - (m_pos + m_page);
571 int AddPos(
int delta)
577 CSize m_originalSize;
578 CSize m_offsetWinToClient;
579 CBarParam m_horizontalParam;
580 CBarParam m_verticalParam;
582 bool m_onThemeChanged;
586 void m_InitScrollInfo(
void)
588 _super::ShowScrollBar(SB_HORZ, FALSE);
589 _super::ShowScrollBar(SB_VERT, FALSE);
591 _super::GetClientRect(rect);
592 m_horizontalParam.SetMax(rect.Width());
593 m_verticalParam.SetMax(rect.Height());
601 void m_OnSize(WPARAM nType,
int cx,
int cy)
603 if ( m_originalSize.cx != 0 )
606 _super::GetWindowRect(rect);
607 bool isEnable = !! (m_originalSize + m_offsetWinToClient != rect.Size());
610 if ( (rect.Height() - m_offsetWinToClient.cy) <= ::GetSystemMetrics(SM_CYHSCROLL) )
615 _super::ScrollWindow(m_horizontalParam.SetPage(cx), m_verticalParam.SetPage(cy));
616 m_horizontalParam.ShowBar(*
this, SB_HORZ, isEnable);
617 m_verticalParam.ShowBar(*
this, SB_VERT, isEnable);
626 void m_OnHScroll(UINT nSBCode, UINT nPos, HWND hScrollBar)
628 if ( hScrollBar == NULL )
630 int delta = m_horizontalParam.Scroll(nSBCode, nPos, m_lineStep);
633 _super::SetScrollPos(SB_HORZ, m_horizontalParam.AddPos(delta), TRUE);
634 _super::ScrollWindow(-delta, 0);
644 void m_OnVScroll(UINT nSBCode, UINT nPos, HWND hScrollBar)
646 if ( hScrollBar == NULL )
648 int delta = m_verticalParam.Scroll(nSBCode, nPos, m_lineStep);
651 _super::SetScrollPos(SB_VERT, m_verticalParam.AddPos(delta), TRUE);
652 _super::ScrollWindow(0, -delta);
664 bool m_OnMouseWheel(UINT fFlags,
short delta, LPARAM lParam)
666 if ( ! m_verticalParam.IsEnable() ) {
return false; }
670 d = m_verticalParam.Scroll(SB_LINEDOWN, 0, (-delta) / 10 + 1);
672 else if ( delta > 0 )
674 d = m_verticalParam.Scroll(SB_LINEUP, 0, (delta) / 10 + 1);
678 _super::SetScrollPos(SB_VERT, m_verticalParam.AddPos(d), TRUE);
679 _super::ScrollWindow(0, -d);
CPaintOrgDC(CResizeDialog *pWnd)
コンストラクタ
CSize GetOriginalWindowSize(void) const
[取得] オリジナルウィンドウサイズ取得.
CResizeDialog(UINT nIDTemplate, CWnd *pParentWnd=NULL)
コンストラクタ
void SetScrollOrg(CDC *pDc, bool isBegin=true) const
[設定] デバイスコンテキストの原点設定、解除.
const CSize & GetOriginalSize(void) const
[取得] オリジナルクライアントサイズ取得.
CResizeDialog(void)
コンストラクタ
void m_CheckOffset(void)
WinとClientの差を計算
void SetLineStep(int s)
[設定] ラインスクロール量設定.
void SetOriginalWindowSize(const SIZE &size)
[設定] オリジナルウィンドウサイズ設定.
void SetOriginalSize(const SIZE &size)
[設定] オリジナルクライアントサイズ設定.
void ChangeOriginalSize(const SIZE &size)
[設定] オリジナルクライアントサイズ変更.
virtual void OnPrintClient(CDC *pDC)
[通知] WM_PRINTCLIENT メッセージ受信.
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
void ResetWindowsSize(void)
[設定] オリジナルウィンドウサイズ化.
CResizeDialog(LPCTSTR lpszTemplateName, CWnd *pParentWnd=NULL)
コンストラクタ
CPoint GetScrollPoint(void) const
[取得] スクロール位置.