MDIBIND: Databound Controls in CWnd-Derived Windows

Click to open or copy the MDIBIND project files.

The MDIBIND sample demonstrates that data binding can be done with any CWnd-derived windows, but only at run time. An AppWizard-generated MDI application is used for this sample. Data source and databound controls are created in CView-derived window client areas.

Running the Sample

You can open/create the child windows based on these templates. With the Bind command from the Window menu, you can bind each control.

For the Grid control and Edit control, choose the data source from any available RDC window and specify the column if required. If the currently selected data source control is active, its results set is used to fill the Column Name box with appropriate column names.

For the Data Source control, you can specify the ODBC data source, user name, password, and SQL statement (just as you can specify these parameters in the resource editor at design time). Note that all bound controls change appropriately when you change the underlying data source name (DSN) by selecting another data source.

Note   The Masked Edit control does not automatically format its contents.

When the Masked Edit Controls Format property is set, it does not automatically format its contents upon losing focus. When embedded in a Visual Basic or Access form, the control automatically formats its contents when the control loses focus.

The Masked Edit Control uses a proprietary Visual Basic interface called IVBFormat. Control container applications written with Visual C++ do not support this interface. The absence of IVBFormat support in a control container prevents the Masked Edit Control from automatically updating its contents as specified by the Format property.

The Masked Edit Control can still be used in a Visual C++ control container application. However, the automatic formatting feature will be disabled. Other properties, like the Mask property and databinding properties function properly in the absence of the IVBFormat support.

This sample demonstrates the following keywords:

CWnd::Create; CWnd::BindProperty; CWnd::BindDefaultProperty;CWnd::GetDSCCursor