Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / WCE samples / DialogDemo / MyDialog.cpp
1 \r
2 #include "MyDialog.h"\r
3 #include "resource.h"\r
4 #include "windowsx.h"\r
5 \r
6 \r
7 CMyDialog::CMyDialog(UINT nResID, CWnd* pParent)\r
8         : CDialog(nResID, pParent), m_nCounter(0)\r
9 {\r
10 }\r
11 \r
12 CMyDialog::~CMyDialog()\r
13 {\r
14 }\r
15 \r
16 void CMyDialog::AddToButton()\r
17 {\r
18         //get the control window\r
19         HWND hwButton = ::GetDlgItem(m_hWnd, IDC_BUTTON1);\r
20         \r
21         //set text to show in control\r
22         TCHAR szBufW[16];\r
23         wsprintf(szBufW, L"Button %d", m_nCounter);\r
24         ::Button_SetText(hwButton, szBufW);\r
25         return;\r
26 }\r
27 \r
28 void CMyDialog::AddToComboBox()\r
29 {\r
30         //get the control window\r
31         HWND hwComboBox = ::GetDlgItem(m_hWnd, IDC_COMBO1);\r
32         \r
33         //set text to show in control\r
34         TCHAR szBufW[16];\r
35         wsprintf(szBufW, L"ComboBox %d", m_nCounter);\r
36         if (m_nCounter)\r
37         {\r
38                 ComboBox_AddString(hwComboBox, szBufW);\r
39                 ::ComboBox_SetText(hwComboBox, szBufW);\r
40                 ComboBox_SetCurSel(hwComboBox, m_nCounter-1);\r
41         }\r
42         else \r
43         {\r
44                 ComboBox_ResetContent(hwComboBox); \r
45                 ComboBox_ShowDropdown(hwComboBox, FALSE);\r
46         }\r
47 }\r
48 \r
49 void CMyDialog::AddToEdit()\r
50 {\r
51         //get the control window\r
52         HWND hwEdit = ::GetDlgItem(m_hWnd, IDC_EDIT1 ); \r
53         \r
54         //set text to show in control\r
55         TCHAR szBufW[16];\r
56         wsprintf(szBufW, L"Edit %d\r\n", m_nCounter);\r
57         if (m_nCounter)\r
58                 Edit_ReplaceSel(hwEdit, szBufW); \r
59         else\r
60                 ::SetWindowText(hwEdit, L""); \r
61 }\r
62 \r
63 void CMyDialog::AddToListBox()\r
64 {\r
65         //get the control window\r
66         HWND hwListBox = ::GetDlgItem(m_hWnd, IDC_LIST1 ); \r
67         \r
68         //set text to show in control\r
69         TCHAR szBufW[16];\r
70         wsprintf(szBufW, L"ListBox %d", m_nCounter);\r
71         if (m_nCounter)\r
72                 ListBox_AddString(hwListBox, szBufW);\r
73         else\r
74                 ListBox_ResetContent(hwListBox); \r
75 }\r
76 \r
77 void CMyDialog::AddToProgressBar()\r
78 {\r
79         //get the control window\r
80         HWND hwProgressBar = ::GetDlgItem(m_hWnd, IDC_PROGRESS1);\r
81         \r
82         //set progress bar position\r
83         SendMessage(hwProgressBar, PBM_SETPOS, (WPARAM)m_nCounter * 10, 0L);\r
84 }\r
85 \r
86 void CMyDialog::AddToScrollBars()\r
87 {\r
88         //get the control window\r
89         HWND hwScrollBarH = ::GetDlgItem(m_hWnd, IDC_SCROLLBAR1);\r
90         HWND hwScrollBarV = ::GetDlgItem(m_hWnd, IDC_SCROLLBAR2);\r
91         \r
92         //set scroll bar range\r
93         ScrollBar_SetRange(hwScrollBarH, 0, 10, FALSE);\r
94         ScrollBar_SetRange(hwScrollBarV, 0, 10, FALSE);\r
95         \r
96         //set scroll bar position\r
97         ScrollBar_SetPos(hwScrollBarH, m_nCounter, TRUE);\r
98         ScrollBar_SetPos(hwScrollBarV, m_nCounter, TRUE);\r
99 }\r
100 \r
101 void CMyDialog::AddToSlider()\r
102 {\r
103         //get the control window\r
104         HWND hwSlider = ::GetDlgItem(m_hWnd, IDC_SLIDER1);\r
105         \r
106         //set slider position\r
107         SendMessage(hwSlider, TBM_SETPOS, TRUE, (WPARAM)m_nCounter * 10);\r
108 }\r
109 \r
110 BOOL CMyDialog::OnInitDialog()\r
111 {\r
112         //Set the Icon\r
113         SetIconLarge(IDW_MAIN);\r
114         SetIconSmall(IDW_MAIN);\r
115 \r
116         // Set a timer to animate the controls on the dialog window\r
117         SetTimer(ID_TIMER, 500, NULL);\r
118 \r
119         return true;\r
120 }\r
121 \r
122 void CMyDialog::OnOK()\r
123 {\r
124         ::MessageBox(NULL, TEXT("DONE Button Pressed.  Program will exit now."), TEXT("Button"), MB_OK);\r
125         CDialog::OnOK();\r
126 }\r
127 \r
128 INT_PTR CMyDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
129 {\r
130     switch (uMsg)\r
131     {\r
132         case WM_TIMER:\r
133                 m_nCounter > 9 ? m_nCounter = 0 : m_nCounter++;\r
134                 AddToEdit();\r
135                 AddToListBox();\r
136                 AddToScrollBars();\r
137                 AddToProgressBar();\r
138                 AddToSlider();\r
139                 AddToComboBox();\r
140                 AddToButton();\r
141     break;\r
142 \r
143     } // switch(uMsg)\r
144         \r
145         return DialogProcDefault(uMsg, wParam, lParam);\r
146         \r
147 } // INT_PTR CALLBACK DialogProc(...)\r
148 \r
149 \r

UCC git Repository :: git.ucc.asn.au