Click here to Skip to main content
15,914,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Stupid question Pin
David.Kelly4-Apr-05 11:04
David.Kelly4-Apr-05 11:04 
Generalchange bitmap button during runtime Pin
Yaron Abershitz26-Mar-05 21:49
Yaron Abershitz26-Mar-05 21:49 
GeneralRe: change bitmap button during runtime Pin
namaskaaram27-Mar-05 16:50
namaskaaram27-Mar-05 16:50 
GeneralEvent Threading Pin
zx2c426-Mar-05 16:30
zx2c426-Mar-05 16:30 
GeneralLinked Lists & Arrays and Locality of Reference Pin
Ziro_026-Mar-05 16:28
Ziro_026-Mar-05 16:28 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Michael Dunn26-Mar-05 20:33
sitebuilderMichael Dunn26-Mar-05 20:33 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Anonymous27-Mar-05 6:05
Anonymous27-Mar-05 6:05 
GeneralVC++ relationship between low-level objkects and GUI interfaces Pin
Anonymous26-Mar-05 10:41
Anonymous26-Mar-05 10:41 
VC++ relationship between low-level objkects and GUI interfaces Question.-

Suppose I have base class A. And subclasses A1, A2, and A3.

class A {...}; // abstract class
class A1 : public A {...}
class A2 : public A {...}
class A3 : public A {...}


I want to allow a user edit A1, A2, or A3 properties through a Dialog Box. Though I have A1Dlg, A2Dlg, A3Dlg:
class A1Dlg : public CDialog {...}
class A2Dlg : public CDialog {...}
class A3Dlg : public CDialog {...}


Then, in my program, I have a list of A object pointers (where I actually have A1, A2 or A3 objects).

// this lines are to explain what I mean, not real code.
// Objects are not instantiated this way, how they are
// created depends on several factors.
A* m_list[n];
m_list[0] = new A1();
m_list[1] = new A3();
m_list[2] = new A2();
...

Question: because my A classes are very "low-level" they don't even know there exists a GUI, or a CDialog class. How can I show the correct Dialog using m_list?

I don't want to do A::displayDialog() because my A classes are very lo-level, they don't know a GUI exists, and they also run on Linux, and win cmd line. Besides that, I want objects to know as less as possible of the rest of the world (don't know if this is conceptually correct in com`puter design). This discards the chance to do:
m_list[x]->displayDialog()


Ugly solution: my solution (very, very ugly) was to declare a methods getType() this way:
enum { a1, a2, a3 } types_t;
types_t getType() = 0; // A class declaration

types_t A1::getType() { return a1; } // A1 implementation
types_t A2::getType() { return a2; } // A1 implementation
types_t A3::getType() { return a3; } // A1 implementation

And I have a "controller" that display the correct dialog box using a switch:
switch (m_list[n]->getType) {
case a1:
// display A1Dlg;
break;
case a2:
// display A2Dlg;
break;
case a3:
// display A3Dlg;
break;
}

Yeah! It is not nice. But This way I have very well separated the data objects (A1, A2, A3) and the view objects (A1Dlg...).

Yes, I've read MVC, but I can't figure it out how to do this "match" in an elegant way.

Can anybodey help? Thanks a lot!
GeneralRe: VC++ relationship between low-level objkects and GUI interfaces Pin
PJ Arends26-Mar-05 11:12
professionalPJ Arends26-Mar-05 11:12 
GeneralGlobal Function Pin
Static(x)26-Mar-05 9:49
Static(x)26-Mar-05 9:49 
GeneralRe: Global Function Pin
PJ Arends26-Mar-05 11:18
professionalPJ Arends26-Mar-05 11:18 
GeneralRestarting the process!! Pliz help Pin
mpapeo26-Mar-05 9:41
mpapeo26-Mar-05 9:41 
GeneralRe: Restarting the process!! Pliz help Pin
Gary R. Wheeler26-Mar-05 13:53
Gary R. Wheeler26-Mar-05 13:53 
GeneralRe: Restarting the process!! Pliz help Pin
mpapeo27-Mar-05 3:04
mpapeo27-Mar-05 3:04 
GeneralRe: Restarting the process!! Pliz help Pin
Gary R. Wheeler27-Mar-05 3:40
Gary R. Wheeler27-Mar-05 3:40 
GeneralRe: Restarting the process!! Pliz help Pin
mpapeo27-Mar-05 4:06
mpapeo27-Mar-05 4:06 
GeneralAES imlementation in VC++ Pin
26-Mar-05 9:08
suss26-Mar-05 9:08 
GeneralFew questions, involving 64 bit file support. Pin
Master Shake 14426-Mar-05 7:32
Master Shake 14426-Mar-05 7:32 
GeneralRe: Few questions, involving 64 bit file support. Pin
Ravi Bhavnani26-Mar-05 12:17
professionalRavi Bhavnani26-Mar-05 12:17 
GeneralRe: Few questions, involving 64 bit file support. Pin
PJ Arends26-Mar-05 12:41
professionalPJ Arends26-Mar-05 12:41 
GeneralRe: Few questions, involving 64 bit file support. Pin
Ravi Bhavnani26-Mar-05 12:44
professionalRavi Bhavnani26-Mar-05 12:44 
GeneralRe: Few questions, involving 64 bit file support. Pin
Graham Bradshaw26-Mar-05 23:37
Graham Bradshaw26-Mar-05 23:37 
GeneralC++ Program Parameter Problem Pin
bneacetp26-Mar-05 6:16
bneacetp26-Mar-05 6:16 
GeneralRe: C++ Program Parameter Problem Pin
valikac26-Mar-05 6:27
valikac26-Mar-05 6:27 
GeneralRe: C++ Program Parameter Problem Pin
bneacetp26-Mar-05 6:50
bneacetp26-Mar-05 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.