Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWIN32 API to find out color monitor v/s monochrome monitor Pin
rajandpayal15-Jun-06 16:00
rajandpayal15-Jun-06 16:00 
AnswerRe: WIN32 API to find out color monitor v/s monochrome monitor Pin
NiceNaidu15-Jun-06 19:56
NiceNaidu15-Jun-06 19:56 
GeneralRe: WIN32 API to find out color monitor v/s monochrome monitor Pin
rajandpayal16-Jun-06 10:41
rajandpayal16-Jun-06 10:41 
GeneralRe: WIN32 API to find out color monitor v/s monochrome monitor Pin
Blake Miller20-Jun-06 9:15
Blake Miller20-Jun-06 9:15 
QuestionModular app design Pin
Anton Afanasyev15-Jun-06 15:25
Anton Afanasyev15-Jun-06 15:25 
AnswerRe: Modular app design Pin
Cedric Moonen15-Jun-06 20:25
Cedric Moonen15-Jun-06 20:25 
QuestionRe: Modular app design Pin
Anton Afanasyev15-Jun-06 21:42
Anton Afanasyev15-Jun-06 21:42 
AnswerRe: Modular app design Pin
Cedric Moonen15-Jun-06 22:28
Cedric Moonen15-Jun-06 22:28 
This can be done quite easily (I think Poke tongue | ;-P ). Make the base class a pure abstract class (so, an interface: no data and all method are pure virtual functions). So, you just have a header file for your base class.

Create dll1 and dll2 in which you implement CWindowType1 and CWindowType2 respectively. Both of these classes inherits from your interface (so, you have to include this base class in the dll's and in your project, that's why it's better to make it a pure abstract class).

In both dll's, add a public method called GetWindowClass (for example) that returns a pointer to the Base class (but in fact create a pointer to the derived class):

CBaseClass* GetWindowClass()
{
   CBaseClass* pNewWindowClass = new CWindowType1;
   return pNewWindowClass;
}


This way, you can handle every dll's exactly the same way and yet still implement different functionalities in it. Of course, you need to load your dll explicitely (with LoadLibrary and GetProcAddress) otherwise this cannot work Roll eyes | :rolleyes: . Are you familiar with that technique ? If not, I suggest you take a look in the MSDN for more information.
So, what you will do at your program startup, is load the specific dll ("WindCls.dll" for example) and get the address of the function GetWindowClass (with GetProcAddress). Call it to get the specific pointer to the "windows system" and you can use it.
You need also to free this pointer later on but this can be done only in the dll. So what you have to do is implement a FreeWindowClass function in the dll that will simply delete the pointer.

And, as a bonus Big Grin | :-D : what you could also do, is write a factory class that will take care of loading several dll's so that you can change the windowing type whenever you want without needing to change the dll's names. But that's just for fun Wink | ;)

Hope this helps


Cédric Moonen
Software developer

Charting control
GeneralRe: Modular app design Pin
Anton Afanasyev16-Jun-06 6:15
Anton Afanasyev16-Jun-06 6:15 
GeneralRe: Modular app design Pin
Cedric Moonen16-Jun-06 9:32
Cedric Moonen16-Jun-06 9:32 
QuestionCasting pointer to pointer of class [modified] Pin
Andre xxxxxxx15-Jun-06 14:31
Andre xxxxxxx15-Jun-06 14:31 
QuestionRe: Casting pointer to pointer of class [modified] Pin
#hackC++15-Jun-06 14:56
#hackC++15-Jun-06 14:56 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Andre xxxxxxx15-Jun-06 15:03
Andre xxxxxxx15-Jun-06 15:03 
AnswerRe: Casting pointer to pointer of class Pin
Michael Dunn15-Jun-06 16:13
sitebuilderMichael Dunn15-Jun-06 16:13 
GeneralRe: Casting pointer to pointer of class Pin
Stephen Hewitt15-Jun-06 18:23
Stephen Hewitt15-Jun-06 18:23 
GeneralRe: Casting pointer to pointer of class Pin
Michael Dunn15-Jun-06 20:41
sitebuilderMichael Dunn15-Jun-06 20:41 
GeneralRe: Casting pointer to pointer of class [modified] Pin
Stephen Hewitt15-Jun-06 20:46
Stephen Hewitt15-Jun-06 20:46 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Arvind Bharti15-Jun-06 17:10
Arvind Bharti15-Jun-06 17:10 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Stephen Hewitt15-Jun-06 18:40
Stephen Hewitt15-Jun-06 18:40 
QuestionLayered Window Question - UpdateLayeredWindow() API [modified] Pin
JeanneBucks15-Jun-06 13:17
JeanneBucks15-Jun-06 13:17 
QuestionHard question about Critical section - in C++ .... Pin
Yanshof15-Jun-06 10:16
Yanshof15-Jun-06 10:16 
AnswerRe: Hard question about Critical section - in C++ .... Pin
Eric Dahlvang15-Jun-06 10:40
Eric Dahlvang15-Jun-06 10:40 
AnswerRe: Hard question about Critical section - in C++ .... Pin
David Crow15-Jun-06 10:46
David Crow15-Jun-06 10:46 
GeneralRe: Hard question - still without answer Pin
Yanshof15-Jun-06 11:40
Yanshof15-Jun-06 11:40 
GeneralRe: Hard question - still without answer Pin
David Crow16-Jun-06 2:33
David Crow16-Jun-06 2:33 

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.