Class design question

From: Bill Thompson (billt61_at_ixnayontheamspayrgv.rr.com)
Date: 10/01/03


Date: Tue, 30 Sep 2003 23:31:43 GMT

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?



Relevant Pages

  • Data Table In MFC
    ... I am new to MFC programming.I want to connect to a database and show a ... tabular format.I donot know which ... control to use. ...
    (microsoft.public.vc.mfc)
  • Re: Data Table In MFC
    ... This control works well for writing strings into static controls on dialogs: ... I am new to MFC programming.I want to connect to a database and show a ...
    (microsoft.public.vc.mfc)
  • Re: How can I use C# GUI component in my MFC application.
    ... Here's some stuff I had written on this topic for my book (Extending MFC ... Using a .NET control in an MFC dialog ... we have seen how Windows Forms makes GUI development slightly easier ... BOOL Create(CWnd* pWnd, int x, int y, int cx, int cy); ...
    (microsoft.public.dotnet.languages.vc)
  • Re: MFC Migration/Integration
    ... I cross post my somewhat frustrated question on MFC ... Check Box, Edit Control, Combo Box, ... List Box, Group Box, Radio Button, Static Text, Picture Control, ... object-oriented techniques (MFC Version 8 with Windows Forms??). ...
    (microsoft.public.vc.mfc)
  • Re: Global datasets
    ... Sticking with the first method again. ... Populate my DataSet from the Database ... Create another control object instance ... re-instantiating it. ...
    (microsoft.public.dotnet.framework.aspnet)