CWnd::GetDSCCursor
IUnknown *GetDSCCursor();
Return Value
A pointer to a cursor that is defined by a data-source control. MFC takes care of calling AddRef for the pointer.
Remarks
Call this member function to retrieve a pointer to the underlying cursor that is defined by the DataSource, UserName, Password, and SQL properties of the data-source control. Use the returned pointer to set the ICursor property of a complex data-bound control, such as the data-bound grid control. A data-source control will not become active until the first bound control requests its cursor. This can happen either explicitly by a call to GetDSCCursor or implicitly by the MFC binding manager. In either case, you can force a data-source control to become active by calling GetDSCCursor and then calling Release on the returned pointer to IUnknown. Activation will cause the data-source control to attempt to connect to the underlying data source. The returned pointer might be used in the following context:
BOOL CMyDlg::OnInitDialog()
{
// Find the child controls on the dialog
CWnd* pDSC = GetDlgItem(IDC_REMOTEDATACONTROL);
CDBListBox* pList = (CDBListBox*)
GetDlgItem(IDC_DBLISTBOX);
// Tell the MFC binding manager that we are
// binding DISPID 3 to the data-source control.
pList->BindProperty(0x3, pDSC);
// Tell the listbox which field to expose as its
// bound column
pList->SetBoundColumn(_T("CourseID"));
// Tell the listbox which cursor and column
// to populate its list from
pList->SetListField(_T("CourseID"));
IPUNKNOWN *pcursor = pDSC->GetDSCCursor();
...
if (!pcursor)
{
// The pointer was not successfully assigned.
return FALSE;
}
// The pointer was successfully assigned,
pList->SetRowSource(pcursor);
...
pcursor->Release();
return TRUE;
}
CWnd Overview | Class Members | Hierarchy Chart
See Also CWnd::BindDefaultProperty, CWnd::BindProperty