Connecting to Data Sources
m_CompanyName = _T(“”); m_ContactName = _T(“”); m_ContactTitle = _T(“”); m_Address = _T(“”); m_City = _T(“”); m_Region = _T(“”); m_PostalCode = _T(“”); m_Country = _T(“”); m_Phone = _T(“”);
m_Fax = _T(“”); m_nFields = 11;
m_nParams = 1; // Number of parameters m_nDefaultType = snapshot;
}
The m_CustomerIDparam member is initialized to an empty string and the parameter count in m_nParams is set to 1.
To set up the m_CustomerIDparam parameter, you add statements to the DoFieldExchange() member, as before:
void CCustomerSet::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Text(pFX, _T(“[CustomerID]”), m_CustomerID); RFX_Text(pFX, _T(“[CompanyName]”), m_CompanyName); RFX_Text(pFX, _T(“[ContactName]”), m_ContactName); RFX_Text(pFX, _T(“[ContactTitle]”), m_ContactTitle); RFX_Text(pFX, _T(“[Address]”), m_Address); RFX_Text(pFX, _T(“[City]”), m_City);
RFX_Text(pFX, _T(“[Region]”), m_Region); RFX_Text(pFX, _T(“[PostalCode]”), m_PostalCode); RFX_Text(pFX, _T(“[Country]”), m_Country); RFX_Text(pFX, _T(“[Phone]”), m_Phone); RFX_Text(pFX, _T(“[Fax]”), m_Fax);
pFX->SetFieldType(CFieldExchange::param); // Set parameter mode RFX_Text(pFX, _T(“CustomerIDParam”), m_CustomerIDparam);
}
I have omitted comment lines from the beginning of this function to save space. After setting the param mode by calling the SetFieldType() member of the pFX object, you call the RFX_Text() function to pass the parameter value for substitution in the filter. You use RFX_Text() because the parameter variable is of type CString. There are various RFX_() functions supporting a range of parameter types.
After you have completed this modification, you can save the CustomerSet.cpp file.
Linking the Order Dialog to the Customer Dialog
To permit a switch to the customer dialog, you require a button control on the IDD_ORDERS_FORM dialog, so open it in Resource View and add an extra button, as shown in Figure 19-30.