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