-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDlgResizeHelper.h
89 lines (77 loc) · 2.41 KB
/
DlgResizeHelper.h
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
83
84
85
86
87
88
89
////////////////////////////////////////////////////////////////////////
// DlgResizeHelper
//
// Author: Stephan Keil ([email protected])
// Date: 2000-06-26
//
// Helps you with keeping dialog layout on resizing.
// It automatically collects all child windows by calling Init() (you
// can also explicitly add other windows by calling Add()) and resizes
// them in OnResize(). Default resizing is proportional to the parent
// window but you can change that behaviour for some or all child windows
// by calling the various Fix() members.
//
//
#ifndef DLGRESIZEHELPER_H_
#define DLGRESIZEHELPER_H_
#pragma warning (disable: 4786)
#include <list>
class DlgResizeHelper
{
public:
// fix horizontal dimension/position
enum EHFix {
kNoHFix = 0,
kWidth = 1,
kLeft = 2,
kRight = 4,
kWidthLeft = 3,
kWidthRight = 5,
kLeftRight = 6
};
// fix vertical dimension/position
enum EVFix {
kNoVFix = 0,
kHeight = 1,
kTop = 2,
kBottom = 4,
kHeightTop = 3,
kHeightBottom = 5,
kTopBottom = 6
};
// initialize with parent window, all child windows must already have
// their original position/size
void Init(HWND a_hParent);
// explicitly add a window to the list of child windows (e.g. a sibling window)
// Note: you've got to call Init() before you can add a window
void Add(HWND a_hWnd);
// fix position/dimension for a child window, determine child by...
// ...HWND...
BOOL Fix(HWND a_hCtrl, EHFix a_hFix, EVFix a_vFix);
// ...item ID (if it's a dialog item)...
BOOL Fix(int a_itemId, EHFix a_hFix, EVFix a_vFix);
/*
// ...all child windows with a common class name (e.g. "Edit")
UINT Fix(LPCTSTR a_pszClassName, EHFix a_hFix, EVFix a_vFix);
*/
// ...or all registered windows
BOOL Fix(EHFix a_hFix, EVFix a_vFix);
// resize child windows according to changes of parent window and fix attributes
void OnSize();
void OnGripperPaint();
void OnGripperNcHitTest(CPoint point, IN OUT UINT& ht);
private:
struct CtrlSize {
CRect m_origSize;
HWND m_hCtrl;
EHFix m_hFix;
EVFix m_vFix;
CtrlSize() : m_hFix(kNoHFix), m_vFix(kNoVFix) {
}
};
typedef std::list<CtrlSize> CtrlCont_t;
CtrlCont_t m_ctrls;
HWND m_hParent;
CRect m_origParentSize;
};
#endif // DLGRESIZEHELPER_H_