Saved resource files with VS2012
[TortoiseGit.git] / ext / ResizableLib / ResizablePageEx.cpp
blob68dac645d963f75c4665c36461927b78098f918a
1 // ResizablePageEx.cpp : implementation file
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // This file is part of ResizableLib
6 // http://sourceforge.net/projects/resizablelib
7 //
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 /////////////////////////////////////////////////////////////////////////////
20 #include "stdafx.h"
21 #include "ResizablePageEx.h"
23 #ifdef _DEBUG
24 #define new DEBUG_NEW
25 #undef THIS_FILE
26 static char THIS_FILE[] = __FILE__;
27 #endif
29 /////////////////////////////////////////////////////////////////////////////
30 // CResizablePageEx
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)
55 ON_WM_SIZE()
56 ON_WM_ERASEBKGND()
57 ON_WM_GETMINMAXINFO()
58 ON_WM_DESTROY()
59 ON_WM_CTLCOLOR()
60 //}}AFX_MSG_MAP
61 END_MESSAGE_MAP()
64 /////////////////////////////////////////////////////////////////////////////
65 // CResizablePageEx message handlers
67 void CResizablePageEx::OnSize(UINT nType, int cx, int cy)
69 CWnd::OnSize(nType, cx, cy);
71 ArrangeLayout();
73 if (m_psp.dwFlags & PSP_HIDEHEADER)
74 Invalidate();
77 BOOL CResizablePageEx::OnEraseBkgnd(CDC* pDC)
79 ClipChildren(pDC, FALSE);
81 BOOL bRet = CPropertyPageEx::OnEraseBkgnd(pDC);
83 ClipChildren(pDC, TRUE);
85 return bRet;
88 void CResizablePageEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
90 MinMaxInfo(lpMMI);
93 BOOL CResizablePageEx::OnInitDialog()
95 CPropertyPageEx::OnInitDialog();
97 // set the initial size as the min track size
98 CRect rc;
99 GetWindowRect(&rc);
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
120 RemoveAllAnchors();
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)
135 CRect rect;
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);
145 return hbr;
148 LRESULT CResizablePageEx::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
150 if (message != WM_NCCALCSIZE || wParam == 0)
151 return CPropertyPageEx::WindowProc(message, wParam, lParam);
153 LRESULT lResult = 0;
154 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
155 lResult = CPropertyPageEx::WindowProc(message, wParam, lParam);
156 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
157 return lResult;