Implementing the Display Dialog Class

DTS Programming

DTS Programming

Implementing the Display Dialog Class

To implement the display and update dialog box in the Data Transformation Services (DTS) custom task user interface example, add code to the header file GVDialog.h. The corresponding code file TaskGVUpdate.cpp contains only include statements.

Add the following to the display and update dialog header file GVDialog.h:

  • An include statement for the component header file and a define statement.

  • Code to initialize controls on the dialog box with values of custom task properties.

  • Code to validate and save the value of the GblVarValue property.

  • A declaration for the task class interface pointer.
Adding an Include and Define Statement

The definition of the task class interface is needed from the component header file. The define is for a buffer length.

Immediately after the line:

#include <atlhost.h>

insert these lines:

#include "DTSTskGVUpdate.h"

#define  MAX_PROP_LEN    2048
Initializating Controls

The Description, GblVarName and GblVarValue properties must be retrieved from the task class and set into controls.

Example

At the head of the OnInitDialog function, insert the following code:

        USES_CONVERSION;
        BSTR            bstrProperty;

        m_pCustTask = (ITaskGVUpdate *)lParam;

        m_pCustTask->get_GblVarName( &bstrProperty );
        SetDlgItemText(IDC_GV_NAME, OLE2T( (LPOLESTR)bstrProperty ) );
        SysFreeString(bstrProperty);

        m_pCustTask->get_GblVarValue( &bstrProperty );
        SetDlgItemText(IDC_GV_VALUE, OLE2T( (LPOLESTR)bstrProperty ) );
        SysFreeString(bstrProperty);

        m_pCustTask->get_Description( &bstrProperty );
        SetDlgItemText(IDC_TASK_DESCR, OLE2T( (LPOLESTR)bstrProperty ) );
        SysFreeString(bstrProperty);
Validating and Updating Properties

The GblVarValue property must be saved back to the task class.

Example

At the head of the OnOK function, insert the following code:

        USES_CONVERSION;
        TCHAR           atcProperty[ MAX_PROP_LEN ];

        // Return updated (?) value of global variable.    
        GetDlgItemText( IDC_GV_VALUE, atcProperty, MAX_PROP_LEN );
        m_pCustTask->put_GblVarValue( T2BSTR( atcProperty ) );
Adding an Interface Pointer Statement

The declaration for the task class interface pointer must be added.

Immediately ahead of the lines:

};

#endif //__GVDIALOG_H_

insert these lines:

private:
    ITaskGVUpdate      * m_pCustTask;