OSDN Git Service

Show Column at Log List
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizableFrame.cpp
1 // ResizableFrame.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 "ResizableFrame.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 // CResizableFrame\r
31 \r
32 IMPLEMENT_DYNCREATE(CResizableFrame, CFrameWnd)\r
33 \r
34 CResizableFrame::CResizableFrame()\r
35 {\r
36         m_bEnableSaveRestore = FALSE;\r
37 }\r
38 \r
39 CResizableFrame::~CResizableFrame()\r
40 {\r
41 }\r
42 \r
43 \r
44 BEGIN_MESSAGE_MAP(CResizableFrame, CFrameWnd)\r
45         //{{AFX_MSG_MAP(CResizableFrame)\r
46         ON_WM_GETMINMAXINFO()\r
47         ON_WM_DESTROY()\r
48         ON_WM_NCCREATE()\r
49         ON_WM_WINDOWPOSCHANGING()\r
50         //}}AFX_MSG_MAP\r
51 END_MESSAGE_MAP()\r
52 \r
53 /////////////////////////////////////////////////////////////////////////////\r
54 // CResizableFrame message handlers\r
55 \r
56 void CResizableFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \r
57 {\r
58         MinMaxInfo(lpMMI);\r
59 \r
60         CView* pView = GetActiveView();\r
61         if (pView == NULL)\r
62                 return;\r
63 \r
64         ChainMinMaxInfo(lpMMI, this, pView);\r
65 }\r
66 \r
67 // NOTE: this must be called after setting the layout\r
68 //       to have the view and its controls displayed properly\r
69 BOOL CResizableFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)\r
70 {\r
71         m_sSection = pszSection;\r
72 \r
73         m_bEnableSaveRestore = TRUE;\r
74         m_bRectOnly = bRectOnly;\r
75 \r
76         // restore immediately\r
77         return LoadWindowRect(pszSection, bRectOnly);\r
78 }\r
79 \r
80 void CResizableFrame::OnDestroy() \r
81 {\r
82         if (m_bEnableSaveRestore)\r
83                 SaveWindowRect(m_sSection, m_bRectOnly);\r
84 \r
85         CFrameWnd::OnDestroy();\r
86 }\r
87 \r
88 BOOL CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct) \r
89 {\r
90         if (!CFrameWnd::OnNcCreate(lpCreateStruct))\r
91                 return FALSE;\r
92 \r
93         MakeResizable(lpCreateStruct);\r
94 \r
95         return TRUE;\r
96 }\r
97 \r
98 LRESULT CResizableFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
99 {\r
100         if (message != WM_NCCALCSIZE || wParam == 0)\r
101                 return CFrameWnd::WindowProc(message, wParam, lParam);\r
102 \r
103         // specifying valid rects needs controls already anchored\r
104         LRESULT lResult = 0;\r
105         HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
106         lResult = CFrameWnd::WindowProc(message, wParam, lParam);\r
107         HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
108         return lResult;\r
109 }\r
110 \r
111 // TODO: implement this in CResizableMinMax\r
112 // We definitely need pluggable message handlers ala WTL!\r
113 void CResizableFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) \r
114 {\r
115         if ((lpwndpos->flags & (SWP_NOSIZE|SWP_NOMOVE)) != (SWP_NOSIZE|SWP_NOMOVE))\r
116                 CFrameWnd::OnWindowPosChanging(lpwndpos);\r
117 }\r