B
Bill Thompson
I'm creating a database application using MFC (Microsoft Foundation
Classes), Visual C++ 6.0. MFC has different classes for each type of data
entry control (e.g. edit boxes, combo boxes).
The interface to the database is the same for all these different control
types, e.g. when the user first attempts to change a value in a control,
attempt to lock the record, or when a control loses focus, attempt to write
the field value.
Since it appears I can't create a generic control class and derive combos
and edit boxes from that class, I'm using multiple inheritance; using
classes that wrap the MFC class and the generic database interface code, as
follows:
class CDbEditCtrl : public CEdit, public CDbControl
{
...
};
class CDbComboCtrl : public CComboBox, public CDbControl
{
...
};
where CEdit and CComboBox are MFC control classes, and CDbControl is the
database interface class.
This allows me to override virtual functions provided by MFC for event
handling etc, while using the generic CDbControl class to interface to the
database.
Could someone kindly suggest a better architecture or technique?
Classes), Visual C++ 6.0. MFC has different classes for each type of data
entry control (e.g. edit boxes, combo boxes).
The interface to the database is the same for all these different control
types, e.g. when the user first attempts to change a value in a control,
attempt to lock the record, or when a control loses focus, attempt to write
the field value.
Since it appears I can't create a generic control class and derive combos
and edit boxes from that class, I'm using multiple inheritance; using
classes that wrap the MFC class and the generic database interface code, as
follows:
class CDbEditCtrl : public CEdit, public CDbControl
{
...
};
class CDbComboCtrl : public CComboBox, public CDbControl
{
...
};
where CEdit and CComboBox are MFC control classes, and CDbControl is the
database interface class.
This allows me to override virtual functions provided by MFC for event
handling etc, while using the generic CDbControl class to interface to the
database.
Could someone kindly suggest a better architecture or technique?