2 #include "MyDialog.h"
\r
3 #include "resource.h"
\r
4 #include "windowsx.h"
\r
7 CMyDialog::CMyDialog(UINT nResID, CWnd* pParent)
\r
8 : CDialog(nResID, pParent), m_nCounter(0)
\r
12 CMyDialog::~CMyDialog()
\r
16 void CMyDialog::AddToButton()
\r
18 //get the control window
\r
19 HWND hwButton = ::GetDlgItem(m_hWnd, IDC_BUTTON1);
\r
21 //set text to show in control
\r
23 wsprintf(szBufW, L"Button %d", m_nCounter);
\r
24 ::Button_SetText(hwButton, szBufW);
\r
28 void CMyDialog::AddToComboBox()
\r
30 //get the control window
\r
31 HWND hwComboBox = ::GetDlgItem(m_hWnd, IDC_COMBO1);
\r
33 //set text to show in control
\r
35 wsprintf(szBufW, L"ComboBox %d", m_nCounter);
\r
38 ComboBox_AddString(hwComboBox, szBufW);
\r
39 ::ComboBox_SetText(hwComboBox, szBufW);
\r
40 ComboBox_SetCurSel(hwComboBox, m_nCounter-1);
\r
44 ComboBox_ResetContent(hwComboBox);
\r
45 ComboBox_ShowDropdown(hwComboBox, FALSE);
\r
49 void CMyDialog::AddToEdit()
\r
51 //get the control window
\r
52 HWND hwEdit = ::GetDlgItem(m_hWnd, IDC_EDIT1 );
\r
54 //set text to show in control
\r
56 wsprintf(szBufW, L"Edit %d\r\n", m_nCounter);
\r
58 Edit_ReplaceSel(hwEdit, szBufW);
\r
60 ::SetWindowText(hwEdit, L"");
\r
63 void CMyDialog::AddToListBox()
\r
65 //get the control window
\r
66 HWND hwListBox = ::GetDlgItem(m_hWnd, IDC_LIST1 );
\r
68 //set text to show in control
\r
70 wsprintf(szBufW, L"ListBox %d", m_nCounter);
\r
72 ListBox_AddString(hwListBox, szBufW);
\r
74 ListBox_ResetContent(hwListBox);
\r
77 void CMyDialog::AddToProgressBar()
\r
79 //get the control window
\r
80 HWND hwProgressBar = ::GetDlgItem(m_hWnd, IDC_PROGRESS1);
\r
82 //set progress bar position
\r
83 SendMessage(hwProgressBar, PBM_SETPOS, (WPARAM)m_nCounter * 10, 0L);
\r
86 void CMyDialog::AddToScrollBars()
\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
92 //set scroll bar range
\r
93 ScrollBar_SetRange(hwScrollBarH, 0, 10, FALSE);
\r
94 ScrollBar_SetRange(hwScrollBarV, 0, 10, FALSE);
\r
96 //set scroll bar position
\r
97 ScrollBar_SetPos(hwScrollBarH, m_nCounter, TRUE);
\r
98 ScrollBar_SetPos(hwScrollBarV, m_nCounter, TRUE);
\r
101 void CMyDialog::AddToSlider()
\r
103 //get the control window
\r
104 HWND hwSlider = ::GetDlgItem(m_hWnd, IDC_SLIDER1);
\r
106 //set slider position
\r
107 SendMessage(hwSlider, TBM_SETPOS, TRUE, (WPARAM)m_nCounter * 10);
\r
110 BOOL CMyDialog::OnInitDialog()
\r
113 SetIconLarge(IDW_MAIN);
\r
114 SetIconSmall(IDW_MAIN);
\r
116 // Set a timer to animate the controls on the dialog window
\r
117 SetTimer(ID_TIMER, 500, NULL);
\r
122 void CMyDialog::OnOK()
\r
124 ::MessageBox(NULL, TEXT("DONE Button Pressed. Program will exit now."), TEXT("Button"), MB_OK);
\r
128 INT_PTR CMyDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
133 m_nCounter > 9 ? m_nCounter = 0 : m_nCounter++;
\r
137 AddToProgressBar();
\r
145 return DialogProcDefault(uMsg, wParam, lParam);
\r
147 } // INT_PTR CALLBACK DialogProc(...)
\r