OSDN Git Service

BrowseRef: Use CMessageBox to display confirm message.
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizableMDIFrame.cpp
1 // ResizableMDIFrame.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 "ResizableMDIFrame.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 // CResizableMDIFrame\r
31 \r
32 IMPLEMENT_DYNCREATE(CResizableMDIFrame, CMDIFrameWnd)\r
33 \r
34 CResizableMDIFrame::CResizableMDIFrame()\r
35 {\r
36         m_bEnableSaveRestore = FALSE;\r
37 }\r
38 \r
39 CResizableMDIFrame::~CResizableMDIFrame()\r
40 {\r
41 }\r
42 \r
43 \r
44 BEGIN_MESSAGE_MAP(CResizableMDIFrame, CMDIFrameWnd)\r
45         //{{AFX_MSG_MAP(CResizableMDIFrame)\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 // CResizableMDIFrame message handlers\r
55 \r
56 void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \r
57 {\r
58         // MDI should call default implementation\r
59         CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);\r
60 \r
61         MinMaxInfo(lpMMI);\r
62 \r
63         BOOL bMaximized = FALSE;\r
64         CMDIChildWnd* pChild = MDIGetActive(&bMaximized);\r
65         if (pChild != NULL && bMaximized)\r
66                 ChainMinMaxInfo(lpMMI, this, pChild);\r
67 }\r
68 \r
69 // NOTE: this must be called after setting the layout\r
70 //       to have the view and its controls displayed properly\r
71 BOOL CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)\r
72 {\r
73         m_sSection = pszSection;\r
74 \r
75         m_bEnableSaveRestore = TRUE;\r
76         m_bRectOnly = bRectOnly;\r
77 \r
78         // restore immediately\r
79         return LoadWindowRect(pszSection, bRectOnly);\r
80 }\r
81 \r
82 void CResizableMDIFrame::OnDestroy() \r
83 {\r
84         if (m_bEnableSaveRestore)\r
85                 SaveWindowRect(m_sSection, m_bRectOnly);\r
86 \r
87         CMDIFrameWnd::OnDestroy();\r
88 }\r
89 \r
90 BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct) \r
91 {\r
92         if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct))\r
93                 return FALSE;\r
94 \r
95         MakeResizable(lpCreateStruct);\r
96         \r
97         return TRUE;\r
98 }\r
99 \r
100 LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
101 {\r
102         if (message != WM_NCCALCSIZE || wParam == 0)\r
103                 return CMDIFrameWnd::WindowProc(message, wParam, lParam);\r
104 \r
105         // specifying valid rects needs controls already anchored\r
106         LRESULT lResult = 0;\r
107         HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
108         lResult = CMDIFrameWnd::WindowProc(message, wParam, lParam);\r
109         HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
110         return lResult;\r
111 }\r
112 \r
113 void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) \r
114 {\r
115         CMDIFrameWnd::OnWindowPosChanging(lpwndpos);\r
116 \r
117         // since this window class doesn't have the style CS_HREDRAW|CS_VREDRAW\r
118         // the client area is not invalidated during a resize operation and\r
119         // this prevents the system from using WM_NCCALCSIZE to validate rects\r
120         Invalidate();\r
121 }\r