-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathResizingDialog.h
More file actions
99 lines (73 loc) · 2.85 KB
/
ResizingDialog.h
File metadata and controls
99 lines (73 loc) · 2.85 KB
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
90
91
92
93
94
95
96
97
98
99
// A flicker-free resizing dialog class
// Copyright (c) 1999 Andy Brown <andy@mirage.dabsol.co.uk>
// You may do whatever you like with this file, I just don't care.
#if !defined(AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_)
#define AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_
#pragma once
#include <vector>
#include "SizeGripWnd.h"
// resizing dialog class
class CResizingDialog : public CDialog
{
public:
DECLARE_DYNCREATE(CResizingDialog)
CResizingDialog(const UINT resID = 0,CWnd *pParent = NULL);
// possible sizing types
enum eSizeType
{
sizeNone, // do nothing
sizeResize, // proportional expand/contract
sizeRepos, // maintain distance from top/left
sizeRelative // proportional distance from sides
};
protected:
// id for the size icon - change if you get a clash with any of your controls
enum { m_idSizeIcon=0x4545 };
// contained class to hold item state
class CItem
{
public:
UINT m_resID; // resource ID
eSizeType m_xSize; // x sizing option
eSizeType m_ySize; // y sizing option
CRect m_rcControl; // last size
bool m_bFlickerFree; // flicker-free move?
double m_xRatio; // x ratio (for relative)
double m_yRatio; // y ratio (for relative)
protected:
void Assign(const CItem& src);
public:
CItem();
CItem(const CItem& src);
void OnSize(HDWP hdwp,const CRect& rcParentOld,const CRect& rcParentNew,CWnd *pDlg);
CItem& operator=(const CItem& src);
};
// data members
std::vector<CItem> m_Items; // array of controlled items
CRect m_rcDialog; // last dialog size
CPoint m_MinSize; // smallest size allowed
eSizeType m_xAllow; // horizontal sizing allowed
eSizeType m_yAllow; // vertical sizing allowed
SizeGripWnd m_wndSizeGrip; // size icon window
bool m_bInited; // set after initialize
protected:
//{{AFX_MSG(CResizingDialog)
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO *lpMMI);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg LRESULT OnNcHitTest(CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual void OnSizeItem(UINT nType, int cx, int cy, HDWP hdwp);
void AddControl(const UINT resID,const eSizeType xsize,const eSizeType ysize,const bool bFlickerFree=true);
void AllowSizing(const eSizeType xsize,const eSizeType ysize);
void HideSizeIcon(void);
public:
//{{AFX_DATA(CResizingDialog)
//}}AFX_DATA
//{{AFX_VIRTUAL(CResizingDialog)
//}}AFX_VIRTUAL
};
//{{AFX_INSERT_LOCATION}}
#endif // !defined(AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_)