-
Notifications
You must be signed in to change notification settings - Fork 1
/
AutoSliderDlgBar.cpp
179 lines (150 loc) · 4.12 KB
/
AutoSliderDlgBar.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Copyleft 2004 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
/*
chris korda
revision history:
rev date comments
00 28sep04 initial version
automation slider dialog
*/
// AutoSliderDlgBar.cpp : implementation file
//
#include "stdafx.h"
#include "Resource.h"
#include "AutoSliderDlgBar.h"
#include "AutoSliderDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAutoSliderDlgBar dialog
CAutoSliderDlgBar::CAutoSliderDlgBar(UINT nIDAccel)
: CDialogBarEx(nIDAccel)
{
//{{AFX_DATA_INIT(CAutoSliderDlgBar)
//}}AFX_DATA_INIT
}
CAutoSliderDlgBar::~CAutoSliderDlgBar()
{
DestroyWindow();
}
void CAutoSliderDlgBar::DoDataExchange(CDataExchange* pDX)
{
CDialogBarEx::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAutoSliderDlgBar)
DDX_Control(pDX, IDC_AUTO_SLIDER, m_Slider);
//}}AFX_DATA_MAP
}
void CAutoSliderDlgBar::TimerHook()
{
if (m_Slider.IsPlaying())
m_Slider.TimerHook();
}
void CAutoSliderDlgBar::GetInfo(CAutoInfo& Info) const
{
m_Slider.GetInfo(Info);
}
void CAutoSliderDlgBar::SetInfo(const CAutoInfo& Info)
{
m_Slider.SetInfo(Info);
SetNormPos(float(Info.m_Pos));
}
BOOL CAutoSliderDlgBar::EnableToolTips(BOOL bEnable)
{
m_Slider.EnableToolTips(bEnable);
return(CDialogBarEx::EnableToolTips(bEnable));
}
void CAutoSliderDlgBar::SaveUndoState(CUndoState& State)
{
WndToUndo(&m_Slider)->SaveUndoState(State);
}
void CAutoSliderDlgBar::RestoreUndoState(const CUndoState& State)
{
WndToUndo(&m_Slider)->RestoreUndoState(State);
}
void CAutoSliderDlgBar::GetUndoTitle(const CUndoState& State, CString& Title)
{
WndToUndo(&m_Slider)->GetUndoTitle(State, Title);
}
void CAutoSliderDlgBar::CMyAutoSliderCtrl::OnNewPos()
{
CAutoSliderDlgBar *asp = (CAutoSliderDlgBar *)GetCookie();
asp->OnPosChange();
}
/////////////////////////////////////////////////////////////////////////////
// CAutoSliderDlgBar overridables
void CAutoSliderDlgBar::OnPosChange()
{
}
BEGIN_MESSAGE_MAP(CAutoSliderDlgBar, CDialogBarEx)
//{{AFX_MSG_MAP(CAutoSliderDlgBar)
ON_WM_CLOSE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_INITDIALOG, OnInitDialog)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTip)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAutoSliderDlgBar message handlers
LRESULT CAutoSliderDlgBar::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
CDialogBarEx::OnInitDialog(wParam, lParam);
m_Slider.SetRange(0, CAutoSliderDlg::SLIDER_RANGE);
m_Slider.CreateTicks(CAutoSliderDlg::SLIDER_TICKS);
m_Slider.SetUndoHandler(this); // override default handling
m_Slider.SetCookie(this); // override slider's OnNewPos
// add controls to resizing object
m_Resize.AddControl(IDC_AUTO_SLIDER, BIND_LEFT | BIND_RIGHT);
m_Resize.FixControls();
return TRUE;
}
void CAutoSliderDlgBar::OnClose()
{
m_Slider.ShowAutoDlg(FALSE);
CDialogBarEx::OnClose();
}
BOOL CAutoSliderDlgBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR *nmh = (NMHDR *)lParam;
switch (nmh->code) {
case AUTOSLIDER_CREATE:
{
CString Text;
GetWindowText(Text);
m_Slider.SetAutoDlgTitle(LDS(AUTO) + " " + Text);
}
break;
case AUTOSLIDER_CLOSE:
m_Slider.SetFocus();
return(TRUE);
}
return CDialogBarEx::OnNotify(wParam, lParam, pResult);
}
void CAutoSliderDlgBar::OnSize(UINT nType, int cx, int cy)
{
CDialogBarEx::OnSize(nType, cx, cy);
m_Resize.OnSize();
}
BOOL CAutoSliderDlgBar::OnToolTip(UINT id, NMHDR* pTTTStruct, LRESULT* pResult)
{
LPNMTTDISPINFO ttp = LPNMTTDISPINFO(pTTTStruct);
UINT nID = ttp->hdr.idFrom;
if (ttp->uFlags & TTF_IDISHWND) // idFrom can be HWND or ID
nID = ::GetDlgCtrlID((HWND)nID);
switch (nID) {
case IDC_AUTO_SLIDER: // auto slider's tooltip is our window text
{
CString s;
GetWindowText(s);
strcpy(ttp->szText, s);
}
return(TRUE);
default:
return(CDialogBarEx::OnToolTip(id, pTTTStruct, pResult));
}
return(FALSE);
}