Class design question

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top