1 // ResizablePageEx.cpp : implementation file
\r
3 /////////////////////////////////////////////////////////////////////////////
\r
5 // This file is part of ResizableLib
\r
6 // http://sourceforge.net/projects/resizablelib
\r
8 // Copyright (C) 2000-2004 by Paolo Messina
\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
\r
11 // The contents of this file are subject to the Artistic License (the "License").
\r
12 // You may not use this file except in compliance with the License.
\r
13 // You may obtain a copy of the License at:
\r
14 // http://www.opensource.org/licenses/artistic-license.html
\r
16 // If you find this code useful, credits would be nice!
\r
18 /////////////////////////////////////////////////////////////////////////////
\r
21 #include "ResizablePageEx.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
32 IMPLEMENT_DYNCREATE(CResizablePageEx, CPropertyPageEx)
\r
34 CResizablePageEx::CResizablePageEx()
\r
38 CResizablePageEx::CResizablePageEx(UINT nIDTemplate, UINT nIDCaption, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle)
\r
39 : CPropertyPageEx(nIDTemplate, nIDCaption, nIDHeaderTitle, nIDHeaderSubTitle)
\r
43 CResizablePageEx::CResizablePageEx(LPCTSTR lpszTemplateName, UINT nIDCaption, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle)
\r
44 : CPropertyPageEx(lpszTemplateName, nIDCaption, nIDHeaderTitle, nIDHeaderSubTitle)
\r
48 CResizablePageEx::~CResizablePageEx()
\r
53 BEGIN_MESSAGE_MAP(CResizablePageEx, CPropertyPageEx)
\r
54 //{{AFX_MSG_MAP(CResizablePageEx)
\r
57 ON_WM_GETMINMAXINFO()
\r
64 /////////////////////////////////////////////////////////////////////////////
\r
65 // CResizablePageEx message handlers
\r
67 void CResizablePageEx::OnSize(UINT nType, int cx, int cy)
\r
69 CWnd::OnSize(nType, cx, cy);
\r
73 if (m_psp.dwFlags & PSP_HIDEHEADER)
\r
77 BOOL CResizablePageEx::OnEraseBkgnd(CDC* pDC)
\r
79 ClipChildren(pDC, FALSE);
\r
81 BOOL bRet = CPropertyPageEx::OnEraseBkgnd(pDC);
\r
83 ClipChildren(pDC, TRUE);
\r
88 void CResizablePageEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
\r
93 BOOL CResizablePageEx::OnInitDialog()
\r
95 CPropertyPageEx::OnInitDialog();
\r
97 // set the initial size as the min track size
\r
100 SetMinTrackSize(rc.Size());
\r
102 // HACK: temporarily abandon subclassing
\r
103 // CAUSE: system subclasses this window after this message
\r
104 // ISSUE: our WindowProc is not the first to be called
\r
105 // and we miss some painting related messages
\r
106 if (Attach(UnsubclassWindow()))
\r
108 CWnd* pParent = GetParent();
\r
109 pParent->LockWindowUpdate();
\r
110 Post_SheetPageExHack(pParent->GetSafeHwnd(), m_hWnd);
\r
113 return TRUE; // return TRUE unless you set the focus to a control
\r
114 // EXCEPTION: OCX Property Pages should return FALSE
\r
117 void CResizablePageEx::OnDestroy()
\r
119 // remove child windows
\r
120 RemoveAllAnchors();
\r
122 CPropertyPageEx::OnDestroy();
\r
125 HBRUSH CResizablePageEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
\r
127 // NOTE: this message couldn't be catched without the above hack
\r
129 HBRUSH hbr = CPropertyPageEx::OnCtlColor(pDC, pWnd, nCtlColor);
\r
130 if (hbr && (m_psp.dwFlags & PSP_HIDEHEADER))
\r
132 // reposition origin of background brush
\r
133 // used for transparent effect on page controls
\r
134 // (needed with double-buffering and XP themes)
\r
136 pWnd->GetWindowRect(rect);
\r
137 pWnd->SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)&rect);
\r
138 ScreenToClient(rect);
\r
139 CPoint pt(-rect.TopLeft());
\r
140 HDC hDC = pDC->GetSafeHdc();
\r
141 ::LPtoDP(hDC, &pt, 1);
\r
142 ::UnrealizeObject(hbr);
\r
143 ::SetBrushOrgEx(hDC, pt.x, pt.y, NULL);
\r
148 LRESULT CResizablePageEx::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
150 if (message != WM_NCCALCSIZE || wParam == 0)
\r
151 return CPropertyPageEx::WindowProc(message, wParam, lParam);
\r
153 LRESULT lResult = 0;
\r
154 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
155 lResult = CPropertyPageEx::WindowProc(message, wParam, lParam);
\r
156 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r