-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinMTRStatusBar.h
126 lines (101 loc) · 2.96 KB
/
WinMTRStatusBar.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef WINMTRSTATUSBAR_H_
#define WINMTRSTATUSBAR_H_
class WinMTRStatusBar : public CStatusBar
{
// Construction
public:
WinMTRStatusBar();
// Attributes
public:
// Operations
public:
int GetPanesCount() const{
return m_nCount;
}
void SetPaneWidth(int nIndex, int nWidth)
{
_STATUSBAR_PANE_ pane;
PaneInfoGet(nIndex, &pane);
pane.cxText = nWidth;
PaneInfoSet(nIndex, &pane);
}
BOOL AddPane(
UINT nID, // ID of the pane
int nIndex // index of the pane
);
BOOL RemovePane(
UINT nID // ID of the pane
);
BOOL AddPaneControl(CWnd* pWnd, UINT nID, BOOL bAutoDestroy)
{
return AddPaneControl( pWnd->GetSafeHwnd(), nID, bAutoDestroy);
}
BOOL AddPaneControl(HWND hWnd, UINT nID, BOOL bAutoDestroy);
void DisableControl( int nIndex, BOOL bDisable=TRUE)
{
UINT uItemID = GetItemID(nIndex);
for ( int i = 0; i < m_arrPaneControls.GetSize(); i++ ){
if( uItemID == m_arrPaneControls[i]->nID ){
if( m_arrPaneControls[i]->hWnd && ::IsWindow(m_arrPaneControls[i]->hWnd) ) {
::EnableWindow(m_arrPaneControls[i]->hWnd, bDisable);
}
}
}
}
void SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth)
{
CStatusBar::SetPaneInfo(nIndex, nID, nStyle, cxWidth);
BOOL bDisabled = ((nStyle&SBPS_DISABLED) == 0);
DisableControl(nIndex, bDisabled);
}
void SetPaneStyle(int nIndex, UINT nStyle)
{
CStatusBar::SetPaneStyle(nIndex, nStyle);
BOOL bDisabled = ((nStyle&SBPS_DISABLED) == 0);
DisableControl(nIndex, bDisabled);
}
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(WinMTRStatusBar)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~WinMTRStatusBar();
protected:
struct _STATUSBAR_PANE_
{
_STATUSBAR_PANE_(){
nID = cxText = nStyle = nFlags = 0;
}
UINT nID; // IDC of indicator: 0 => normal text area
int cxText; // width of string area in pixels
// on both sides there is a 3 pixel gap and
// a one pixel border, making a pane 6 pixels wider
UINT nStyle; // style flags (SBPS_*)
UINT nFlags; // state flags (SBPF_*)
CString strText; // text in the pane
};
struct _STATUSBAR_PANE_CTRL_
{
HWND hWnd;
UINT nID;
BOOL bAutoDestroy;
};
CArray < _STATUSBAR_PANE_CTRL_*, _STATUSBAR_PANE_CTRL_* > m_arrPaneControls;
_STATUSBAR_PANE_* GetPanePtr(int nIndex) const
{
ASSERT((nIndex >= 0 && nIndex < m_nCount) || m_nCount == 0);
return ((_STATUSBAR_PANE_*)m_pData) + nIndex;
}
BOOL PaneInfoGet(int nIndex, _STATUSBAR_PANE_* pPane);
BOOL PaneInfoSet(int nIndex, _STATUSBAR_PANE_* pPane);
void RepositionControls();
// Generated message map functions
protected:
//{{AFX_MSG(WinMTRStatusBar)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};
#endif // WINMTRSTATUSBAR_H_