다음을 통해 공유


CWnd::GetDSCCursor

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.

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

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:

Example

BOOL CMyDlg::OnInitDialog()
{


...


// Find the child controls on the dialog
HRESULT hr = E_FAIL;
CWnd* pDSC = GetDlgItem(IDC_DATASOURCE);
CWnd* pListWnd = GetDlgItem(IDC_DBLIST1);
IUnknown* punkList = pListWnd->GetControlUnknown();
IDBList* pList = NULL;

if (NULL != punkList)
{
   hr = punkList->QueryInterface(__uuidof(IDBList), (void**)&pList);
}

if (SUCCEEDED(hr))
{
   // Tell the MFC binding manager that we are
   // binding DISPID 3 to the data-source control.
   pListWnd->BindProperty(0x3, pDSC);

   // Tell the listbox which field to expose as its bound column
   pList->put_BoundColumn(_T("ContactFirstName"));

   // Tell the listbox which cursor and column to populate its list from
   pList->put_ListField(_T("ContactFirstName"));

   IUnknown* punkCursor = pDSC->GetDSCCursor();
   if (NULL != punkCursor)
   {
      punkCursor->Release();
   }

   pList->Release();


...


    return TRUE;
}

Requirements

Header: afxwin.h

See Also

Reference

CWnd Class

Hierarchy Chart

CWnd::BindDefaultProperty

CWnd::BindProperty

Concepts

CWnd Members