OSDN Git Service

Create TortoiseGitBlame
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizablePageEx.cpp
1 // ResizablePageEx.cpp : implementation file\r
2 //\r
3 /////////////////////////////////////////////////////////////////////////////\r
4 //\r
5 // This file is part of ResizableLib\r
6 // http://sourceforge.net/projects/resizablelib\r
7 //\r
8 // Copyright (C) 2000-2004 by Paolo Messina\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com\r
10 //\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
15 //\r
16 // If you find this code useful, credits would be nice!\r
17 //\r
18 /////////////////////////////////////////////////////////////////////////////\r
19 \r
20 #include "stdafx.h"\r
21 #include "ResizablePageEx.h"\r
22 \r
23 #ifdef _DEBUG\r
24 #define new DEBUG_NEW\r
25 #undef THIS_FILE\r
26 static char THIS_FILE[] = __FILE__;\r
27 #endif\r
28 \r
29 /////////////////////////////////////////////////////////////////////////////\r
30 // CResizablePageEx\r
31 \r
32 IMPLEMENT_DYNCREATE(CResizablePageEx, CPropertyPageEx)\r
33 \r
34 CResizablePageEx::CResizablePageEx()\r
35 {\r
36 }\r
37 \r
38 CResizablePageEx::CResizablePageEx(UINT nIDTemplate, UINT nIDCaption, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle)\r
39         : CPropertyPageEx(nIDTemplate, nIDCaption, nIDHeaderTitle, nIDHeaderSubTitle)\r
40 {\r
41 }\r
42 \r
43 CResizablePageEx::CResizablePageEx(LPCTSTR lpszTemplateName, UINT nIDCaption, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle)\r
44         : CPropertyPageEx(lpszTemplateName, nIDCaption, nIDHeaderTitle, nIDHeaderSubTitle)\r
45 {\r
46 }\r
47 \r
48 CResizablePageEx::~CResizablePageEx()\r
49 {\r
50 }\r
51 \r
52 \r
53 BEGIN_MESSAGE_MAP(CResizablePageEx, CPropertyPageEx)\r
54         //{{AFX_MSG_MAP(CResizablePageEx)\r
55         ON_WM_SIZE()\r
56         ON_WM_ERASEBKGND()\r
57         ON_WM_GETMINMAXINFO()\r
58         ON_WM_DESTROY()\r
59         ON_WM_CTLCOLOR()\r
60         //}}AFX_MSG_MAP\r
61 END_MESSAGE_MAP()\r
62 \r
63 \r
64 /////////////////////////////////////////////////////////////////////////////\r
65 // CResizablePageEx message handlers\r
66 \r
67 void CResizablePageEx::OnSize(UINT nType, int cx, int cy) \r
68 {\r
69         CWnd::OnSize(nType, cx, cy);\r
70         \r
71         ArrangeLayout();\r
72 \r
73         if (m_psp.dwFlags & PSP_HIDEHEADER)\r
74                 Invalidate();\r
75 }\r
76 \r
77 BOOL CResizablePageEx::OnEraseBkgnd(CDC* pDC) \r
78 {\r
79         ClipChildren(pDC, FALSE);\r
80 \r
81         BOOL bRet = CPropertyPageEx::OnEraseBkgnd(pDC);\r
82 \r
83         ClipChildren(pDC, TRUE);\r
84 \r
85         return bRet;\r
86 }\r
87 \r
88 void CResizablePageEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \r
89 {\r
90         MinMaxInfo(lpMMI);\r
91 }\r
92 \r
93 BOOL CResizablePageEx::OnInitDialog() \r
94 {\r
95         CPropertyPageEx::OnInitDialog();\r
96         \r
97         // set the initial size as the min track size\r
98         CRect rc;\r
99         GetWindowRect(&rc);\r
100         SetMinTrackSize(rc.Size());\r
101 \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
107         {\r
108                 CWnd* pParent = GetParent();\r
109                 pParent->LockWindowUpdate();\r
110                 Post_SheetPageExHack(pParent->GetSafeHwnd(), m_hWnd);\r
111         }\r
112 \r
113         return TRUE;  // return TRUE unless you set the focus to a control\r
114                       // EXCEPTION: OCX Property Pages should return FALSE\r
115 }\r
116 \r
117 void CResizablePageEx::OnDestroy() \r
118 {\r
119         // remove child windows\r
120         RemoveAllAnchors();\r
121 \r
122         CPropertyPageEx::OnDestroy();\r
123 }\r
124 \r
125 HBRUSH CResizablePageEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) \r
126 {\r
127         // NOTE: this message couldn't be catched without the above hack\r
128 \r
129         HBRUSH hbr = CPropertyPageEx::OnCtlColor(pDC, pWnd, nCtlColor);\r
130         if (hbr && (m_psp.dwFlags & PSP_HIDEHEADER))\r
131         {\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
135                 CRect rect;\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
144         }\r
145         return hbr;\r
146 }\r
147 \r
148 LRESULT CResizablePageEx::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
149 {\r
150         if (message != WM_NCCALCSIZE || wParam == 0)\r
151                 return CPropertyPageEx::WindowProc(message, wParam, lParam);\r
152 \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
157         return lResult;\r
158 }\r