Mercurial > vba-linux
comparison src/win32/RewindInterval.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // RewindInterval.cpp : implementation file | |
2 // | |
3 | |
4 #include "stdafx.h" | |
5 #include <cmath> | |
6 #include "resource.h" | |
7 #include "RewindInterval.h" | |
8 #include "VBA.h" | |
9 | |
10 ///////////////////////////////////////////////////////////////////////////// | |
11 // RewindInterval dialog | |
12 | |
13 RewindInterval::RewindInterval(float interval, int slots, CWnd*pParent /*=NULL*/) | |
14 : CDialog(RewindInterval::IDD, pParent) | |
15 { | |
16 //{{AFX_DATA_INIT(RewindInterval) | |
17 // NOTE: the ClassWizard will add member initialization here | |
18 //}}AFX_DATA_INIT | |
19 this->interval = interval; | |
20 this->slots = slots; | |
21 } | |
22 | |
23 void RewindInterval::DoDataExchange(CDataExchange*pDX) | |
24 { | |
25 CDialog::DoDataExchange(pDX); | |
26 //{{AFX_DATA_MAP(RewindInterval) | |
27 DDX_Control(pDX, IDC_INTERVAL, m_interval); | |
28 DDX_Control(pDX, IDC_REWINDSLOTS, m_slots); | |
29 //}}AFX_DATA_MAP | |
30 } | |
31 | |
32 BEGIN_MESSAGE_MAP(RewindInterval, CDialog) | |
33 //{{AFX_MSG_MAP(RewindInterval) | |
34 ON_BN_CLICKED(ID_CANCEL, OnCancel) | |
35 ON_BN_CLICKED(ID_OK, OnOk) | |
36 //}}AFX_MSG_MAP | |
37 END_MESSAGE_MAP() | |
38 | |
39 ///////////////////////////////////////////////////////////////////////////// | |
40 // RewindInterval message handlers | |
41 | |
42 void RewindInterval::OnCancel() | |
43 { | |
44 EndDialog(-1); | |
45 } | |
46 | |
47 void RewindInterval::OnOk() | |
48 { | |
49 CString buffer, buffer2; | |
50 | |
51 m_interval.GetWindowText(buffer); | |
52 m_slots.GetWindowText(buffer2); | |
53 | |
54 float interval = (float)atof(buffer); | |
55 int slots = atoi(buffer2); | |
56 | |
57 if (interval >= 0 && (int)interval <= 600) | |
58 { | |
59 if (slots >= 0 && slots <= MAX_REWIND_SLOTS) | |
60 { | |
61 int iInterval = (int)(interval*6.0f + 0.5f); | |
62 if (interval > 0 && iInterval == 0) | |
63 iInterval = 1; | |
64 EndDialog(iInterval | (slots << 16)); | |
65 theApp.winAccelMgr.UpdateMenu(theApp.menu); | |
66 } | |
67 else | |
68 systemMessage(IDS_INVALID_INTERVAL_VALUE, | |
69 "Invalid rewind slot amount. Please enter a number " | |
70 "between 0 and 128 slots"); | |
71 } | |
72 else | |
73 systemMessage(IDS_INVALID_INTERVAL_VALUE, | |
74 "Invalid rewind interval value. Please enter a number " | |
75 "between 0 and 600 seconds"); | |
76 } | |
77 | |
78 BOOL RewindInterval::OnInitDialog() | |
79 { | |
80 CDialog::OnInitDialog(); | |
81 | |
82 m_interval.LimitText(5); | |
83 m_slots.LimitText(3); | |
84 | |
85 CString buffer, buffer2; | |
86 buffer.Format("%.1f", interval); | |
87 m_interval.SetWindowText(buffer); | |
88 buffer2.Format("%d", slots); | |
89 m_slots.SetWindowText(buffer2); | |
90 | |
91 CenterWindow(); | |
92 | |
93 return TRUE; // return TRUE unless you set the focus to a control | |
94 // EXCEPTION: OCX Property Pages should return FALSE | |
95 } | |
96 |