Scroll event example for C++ 4.0 and later

1. Add a Static Text control as follows:

a. In the Project Workspace, click the ResourceView tab.

b. Double-click the tutor resources folder to open it.

c. Double-click the Dialog folder to open it.

d. Double-click IDD_TUTOR_DIALOG to design the dialog box.

e. Click the Static Text control; then click and drag its shape in the dialog box.

f. Double-click the new control to edit its properties.

g. Change the ID to IDC_TEXT1.

h. Press Ctrl-F4 to close all windows back to the Project Workspace.

2. Do the following to add m_Text1 to the CTutorDlg class and link the variable to the Static Text control using dynamic data exchange:

a. Press Ctrl-W to go to the MFC ClassWizard.

b. Click the Member Variables tab.

c. In the Class Name box, select CTutorDlg.

d. In the Control IDs list, select IDC_TEXT1.

e. Click the Add Variable... button.

f. Specify m_Text1 as the variable name, Control as the category, and Cstatic as the variable type.

g. Click OK to close the dialog box, and click OK to close the MFC ClassWizard.

3. Edit the Lead1_OnScroll procedure as follows:

VOID CSampleDlg::Lead1_OnScroll()
{
  char cStr[128];
  sprintf(cStr, "Image origin: %g, %g", (double) m_Lead1.GetDstLeft(), (double) m_Lead1.GetDstTop());
  m_Text1.SetWindowText(cStr);
  m_Text1.UpdateWindow();
}