-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBarContainerDialog.cpp
82 lines (70 loc) · 1.94 KB
/
BarContainerDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// BarContainerDialog.cpp : implementation file
//
#include "stdafx.h"
#include "SCIPicEditor.h"
#include "BarContainerDialog.h"
// CBarContainerDialog dialog
CBarContainerDialog::CBarContainerDialog(CWnd* pParent /*=NULL*/)
: CExtResizableDialog(CBarContainerDialog::IDD, pParent)
{
}
CBarContainerDialog::~CBarContainerDialog()
{
}
void CBarContainerDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CBarContainerDialog, CExtResizableDialog)
ON_WM_SIZE()
END_MESSAGE_MAP()
// Some incredibly overzealous use of functors
template<class _T>
class ResizeWindows
{
public:
ResizeWindows(int cx, int cy) : _cx(cx), _cy(cy) {}
void operator()(typename _T::value_type &window)
{
if (window.second)
{
window.second->SetWindowPos(NULL, 0, 0, _cx, _cy, SWP_NOMOVE | SWP_NOZORDER);
}
}
private:
int _cx, _cy;
};
template<class _T>
class HideWindowsExcept
{
public:
HideWindowsExcept(CWnd *pWnd) : _pWndException(pWnd) {}
void operator()(typename _T::value_type &window)
{
if (window.second && (window.second != _pWndException))
{
window.second->ShowWindow(SW_HIDE);
}
}
private:
CWnd *_pWndException;
};
void CBarContainerDialog::OnSize(UINT nType, int cx, int cy)
{
// Resize all our children to be just like us.
for_each(_childWindows.begin(), _childWindows.end(), ResizeWindows<windowmap>(cx, cy));
}
// CBarContainerDialog message handlers
void CBarContainerDialog::SelectChild(CWnd *pWnd, int iType)
{
ASSERT((pWnd == NULL) || (pWnd->GetParent() == static_cast<CWnd*>(this)));
_childWindows[iType] = pWnd;
for_each(_childWindows.begin(), _childWindows.end(), HideWindowsExcept<windowmap>(pWnd));
if (pWnd)
{
CRect rc;
GetClientRect(&rc);
pWnd->SetWindowPos(NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE | SWP_NOZORDER);
pWnd->ShowWindow(SW_SHOW);
}
}