Update UNRAR.H
[xy_vsfilter.git] / src / ui / ResizableLib / ResizableDialog.cpp
blobd61d4472b8fa69c315937f2344fe18c77151d82e
1 // ResizableDialog.cpp : implementation file
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2000-2002 by Paolo Messina
6 // (http://www.geocities.com/ppescher - ppescher@yahoo.com)
7 //
8 // The contents of this file are subject to the Artistic License (the "License").
9 // You may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at:
11 // http://www.opensource.org/licenses/artistic-license.html
13 // If you find this code useful, credits would be nice!
15 /////////////////////////////////////////////////////////////////////////////
17 #include "stdafx.h"
18 #include "ResizableDialog.h"
20 #ifdef _DEBUG
21 #define new DEBUG_NEW
22 #undef THIS_FILE
23 static char THIS_FILE[] = __FILE__;
24 #endif
26 /////////////////////////////////////////////////////////////////////////////
27 // CResizableDialog
29 inline void CResizableDialog::PrivateConstruct()
31 m_bEnableSaveRestore = FALSE;
32 m_dwGripTempState = 1;
35 CResizableDialog::CResizableDialog()
37 PrivateConstruct();
40 CResizableDialog::CResizableDialog(UINT nIDTemplate, CWnd* pParentWnd)
41 : CCmdUIDialog(nIDTemplate, pParentWnd)
43 PrivateConstruct();
46 CResizableDialog::CResizableDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
47 : CCmdUIDialog(lpszTemplateName, pParentWnd)
49 PrivateConstruct();
52 CResizableDialog::~CResizableDialog()
57 BEGIN_MESSAGE_MAP(CResizableDialog, CCmdUIDialog)
58 //{{AFX_MSG_MAP(CResizableDialog)
59 ON_WM_GETMINMAXINFO()
60 ON_WM_SIZE()
61 ON_WM_DESTROY()
62 ON_WM_CREATE()
63 ON_WM_ERASEBKGND()
64 //}}AFX_MSG_MAP
65 END_MESSAGE_MAP()
68 /////////////////////////////////////////////////////////////////////////////
69 // CResizableDialog message handlers
71 int CResizableDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
73 if (__super::OnCreate(lpCreateStruct) == -1)
74 return -1;
76 // child dialogs don't want resizable border or size grip,
77 // nor they can handle the min/max size constraints
78 BOOL bChild = GetStyle() & WS_CHILD;
80 if (!bChild)
82 // keep client area
83 CRect rect;
84 GetClientRect(&rect);
85 // set resizable style
86 ModifyStyle(DS_MODALFRAME, WS_POPUP | WS_THICKFRAME);
87 // adjust size to reflect new style
88 ::AdjustWindowRectEx(&rect, GetStyle(),
89 ::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle());
90 SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_FRAMECHANGED|
91 SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREPOSITION);
93 // set the initial size as the min track size
94 SetMinTrackSize(rect.Size());
97 // create and init the size-grip
98 if (!CreateSizeGrip(!bChild))
99 return -1;
101 return 0;
104 void CResizableDialog::OnDestroy()
106 if (m_bEnableSaveRestore)
107 SaveWindowRect(m_sSection, m_bRectOnly);
109 // remove child windows
110 RemoveAllAnchors();
112 __super::OnDestroy();
115 void CResizableDialog::OnSize(UINT nType, int cx, int cy)
117 CWnd::OnSize(nType, cx, cy);
119 if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
120 return; // arrangement not needed
122 if (nType == SIZE_MAXIMIZED)
123 HideSizeGrip(&m_dwGripTempState);
124 else
125 ShowSizeGrip(&m_dwGripTempState);
127 // update grip and layout
128 UpdateSizeGrip();
129 ArrangeLayout();
132 void CResizableDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
134 MinMaxInfo(lpMMI);
137 // NOTE: this must be called after setting the layout
138 // to have the dialog and its controls displayed properly
139 void CResizableDialog::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
141 m_sSection = pszSection;
143 m_bEnableSaveRestore = TRUE;
144 m_bRectOnly = bRectOnly;
146 // restore immediately
147 LoadWindowRect(pszSection, bRectOnly);
151 BOOL CResizableDialog::OnEraseBkgnd(CDC* pDC)
153 // Windows XP doesn't like clipping regions ...try this!
154 EraseBackground(pDC);
155 return TRUE;
157 /* ClipChildren(pDC); // old-method (for safety)
159 return CDialog::OnEraseBkgnd(pDC);