X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fhonours.git;a=blobdiff_plain;f=research%2Ftransmission_spectroscopy%2FTOF%2FWin32%2B%2B%2FWCE%20samples%2FDialogDemo%2FMyDialog.cpp;fp=research%2Ftransmission_spectroscopy%2FTOF%2FWin32%2B%2B%2FWCE%20samples%2FDialogDemo%2FMyDialog.cpp;h=9983329bb3b0abd271c790f12e99ad44edb3dd71;hp=0000000000000000000000000000000000000000;hb=70a96cca12cb006506461d26cd112bab179fe74c;hpb=8caf60af39689a3546074f0c68d14c3a2e28191e diff --git a/research/transmission_spectroscopy/TOF/Win32++/WCE samples/DialogDemo/MyDialog.cpp b/research/transmission_spectroscopy/TOF/Win32++/WCE samples/DialogDemo/MyDialog.cpp new file mode 100644 index 00000000..9983329b --- /dev/null +++ b/research/transmission_spectroscopy/TOF/Win32++/WCE samples/DialogDemo/MyDialog.cpp @@ -0,0 +1,149 @@ + +#include "MyDialog.h" +#include "resource.h" +#include "windowsx.h" + + +CMyDialog::CMyDialog(UINT nResID, CWnd* pParent) + : CDialog(nResID, pParent), m_nCounter(0) +{ +} + +CMyDialog::~CMyDialog() +{ +} + +void CMyDialog::AddToButton() +{ + //get the control window + HWND hwButton = ::GetDlgItem(m_hWnd, IDC_BUTTON1); + + //set text to show in control + TCHAR szBufW[16]; + wsprintf(szBufW, L"Button %d", m_nCounter); + ::Button_SetText(hwButton, szBufW); + return; +} + +void CMyDialog::AddToComboBox() +{ + //get the control window + HWND hwComboBox = ::GetDlgItem(m_hWnd, IDC_COMBO1); + + //set text to show in control + TCHAR szBufW[16]; + wsprintf(szBufW, L"ComboBox %d", m_nCounter); + if (m_nCounter) + { + ComboBox_AddString(hwComboBox, szBufW); + ::ComboBox_SetText(hwComboBox, szBufW); + ComboBox_SetCurSel(hwComboBox, m_nCounter-1); + } + else + { + ComboBox_ResetContent(hwComboBox); + ComboBox_ShowDropdown(hwComboBox, FALSE); + } +} + +void CMyDialog::AddToEdit() +{ + //get the control window + HWND hwEdit = ::GetDlgItem(m_hWnd, IDC_EDIT1 ); + + //set text to show in control + TCHAR szBufW[16]; + wsprintf(szBufW, L"Edit %d\r\n", m_nCounter); + if (m_nCounter) + Edit_ReplaceSel(hwEdit, szBufW); + else + ::SetWindowText(hwEdit, L""); +} + +void CMyDialog::AddToListBox() +{ + //get the control window + HWND hwListBox = ::GetDlgItem(m_hWnd, IDC_LIST1 ); + + //set text to show in control + TCHAR szBufW[16]; + wsprintf(szBufW, L"ListBox %d", m_nCounter); + if (m_nCounter) + ListBox_AddString(hwListBox, szBufW); + else + ListBox_ResetContent(hwListBox); +} + +void CMyDialog::AddToProgressBar() +{ + //get the control window + HWND hwProgressBar = ::GetDlgItem(m_hWnd, IDC_PROGRESS1); + + //set progress bar position + SendMessage(hwProgressBar, PBM_SETPOS, (WPARAM)m_nCounter * 10, 0L); +} + +void CMyDialog::AddToScrollBars() +{ + //get the control window + HWND hwScrollBarH = ::GetDlgItem(m_hWnd, IDC_SCROLLBAR1); + HWND hwScrollBarV = ::GetDlgItem(m_hWnd, IDC_SCROLLBAR2); + + //set scroll bar range + ScrollBar_SetRange(hwScrollBarH, 0, 10, FALSE); + ScrollBar_SetRange(hwScrollBarV, 0, 10, FALSE); + + //set scroll bar position + ScrollBar_SetPos(hwScrollBarH, m_nCounter, TRUE); + ScrollBar_SetPos(hwScrollBarV, m_nCounter, TRUE); +} + +void CMyDialog::AddToSlider() +{ + //get the control window + HWND hwSlider = ::GetDlgItem(m_hWnd, IDC_SLIDER1); + + //set slider position + SendMessage(hwSlider, TBM_SETPOS, TRUE, (WPARAM)m_nCounter * 10); +} + +BOOL CMyDialog::OnInitDialog() +{ + //Set the Icon + SetIconLarge(IDW_MAIN); + SetIconSmall(IDW_MAIN); + + // Set a timer to animate the controls on the dialog window + SetTimer(ID_TIMER, 500, NULL); + + return true; +} + +void CMyDialog::OnOK() +{ + ::MessageBox(NULL, TEXT("DONE Button Pressed. Program will exit now."), TEXT("Button"), MB_OK); + CDialog::OnOK(); +} + +INT_PTR CMyDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_TIMER: + m_nCounter > 9 ? m_nCounter = 0 : m_nCounter++; + AddToEdit(); + AddToListBox(); + AddToScrollBars(); + AddToProgressBar(); + AddToSlider(); + AddToComboBox(); + AddToButton(); + break; + + } // switch(uMsg) + + return DialogProcDefault(uMsg, wParam, lParam); + +} // INT_PTR CALLBACK DialogProc(...) + +