Click here to Skip to main content
15,914,419 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Restricting a BHO Pin
Jason De Arte10-Feb-04 7:04
Jason De Arte10-Feb-04 7:04 
GeneralRe: Restricting a BHO Pin
macattack10-Feb-04 7:18
macattack10-Feb-04 7:18 
QuestionHow to add a help file into a wtl dialog? Pin
freehawk8-Feb-04 19:27
freehawk8-Feb-04 19:27 
GeneralError in wizard Pin
SiddharthAtw8-Feb-04 18:16
SiddharthAtw8-Feb-04 18:16 
GeneralRe: Error in wizard Pin
Simon.W9-Feb-04 1:12
Simon.W9-Feb-04 1:12 
QuestionIdentical methods/properties in separate interfaces ? Pin
Alwin756-Feb-04 0:16
Alwin756-Feb-04 0:16 
AnswerRe: Identical methods/properties in separate interfaces ? Pin
_Magnus_6-Feb-04 2:43
_Magnus_6-Feb-04 2:43 
AnswerRe: Identical methods/properties in separate interfaces ? Pin
Jörgen Sigvardsson7-Feb-04 23:01
Jörgen Sigvardsson7-Feb-04 23:01 
What you may have to do is what's sometimes called forwarding shims. The trick is to "prebind" the virtual methods. Observe:
class IFirstFwd : public IFirst {
public:
    HRESULT Test() {
         return IFirst_Test();
    }
 
    virtual HRESULT IFirst_Test() = 0;
};
 
class ISecondFwd : public ISecond {
public:
     HRESULT Test() {
         return ISecond_Test();
     }
  
     virtual HRESULT ISecond_Test() = 0;
};
 
class CYourComClass : public IFirstFwd, public ISecondFwd {
public:
     HRESULT IFirst_Test() {
          ...
     }

     HRESULT ISecond_Test() {
          ...
     }
};
I know it looks clumbsy, but since C++ does not have a feature for renaming inherited methods, this is the most type safe way to do it. Ok, so know that you know how it works, let's cut off those extra 8 bytes from the vtable (on wintel ia32) by adding templates:
template <typename T> 
class IFirstFwd : public IFirst {
public:    
     HRESULT Test() {
         return static_cast<T*>(this)->IFirst_Test();
     }
};
 
template <typename T> 
class ISecondFwd : public ISecond {
public:    
     HRESULT Test() {
         return static_cast<T*>(this)->ISecond_Test();
     }
};
 
class CYourComClass : public IFirstFwd<CYourComClass>, public ISecondFwd<CYourComClass> {
public:
     HRESULT IFirst_Test() {
          ...
     }

     HRESULT ISecond_Test() {
          ...
     }
};
There is another way - although not very pretty IMHO. It will only work well once the interfaces have finalized. I.e., this is very bad during development, because you lose all the help from the type system, and the bugs you may potentially have will be less than fun to figure out:
class ISecondFake {
    // Copy the methods from ISecond and past it here
    // Prefix all mthods with ISecond_
    virtual __stdcall HRESULT ISecond_Test() = 0;
};

class CYourComClass : public IFirst, public ISecondFake {
public:
     HRESULT Test() { // IFirst version
          ...
     }

     HRESULT ISecond_Test() {
          ...
     }
};
This'll work as long as your ISecondFake is vtable-compatible with ISecond. But should you change the vtable layout or method signature of ISecond in any way, don't forget to update ISecondFake or you'll be in for quite the ride.. Smile | :)

--
Gott weiß ich will kein Engel sein.
QuestionHow can i get properties of com object dynamically Pin
Inam5-Feb-04 19:46
Inam5-Feb-04 19:46 
AnswerRe: How can i get properties of com object dynamically Pin
Jörgen Sigvardsson5-Feb-04 21:37
Jörgen Sigvardsson5-Feb-04 21:37 
GeneralAbout CString Pin
freehawk5-Feb-04 18:48
freehawk5-Feb-04 18:48 
GeneralRe: About CString Pin
Jörgen Sigvardsson5-Feb-04 21:35
Jörgen Sigvardsson5-Feb-04 21:35 
QuestionHow to get a double-click message? Pin
freehawk4-Feb-04 21:35
freehawk4-Feb-04 21:35 
AnswerRe: How to get a double-click message? Pin
_Magnus_5-Feb-04 0:11
_Magnus_5-Feb-04 0:11 
GeneralRe: How to get a double-click message? Pin
freehawk5-Feb-04 1:25
freehawk5-Feb-04 1:25 
GeneralRe: How to get a double-click message? Pin
Jörgen Sigvardsson5-Feb-04 8:06
Jörgen Sigvardsson5-Feb-04 8:06 
GeneralRe: How to get a double-click message? Pin
Jörgen Sigvardsson5-Feb-04 8:04
Jörgen Sigvardsson5-Feb-04 8:04 
GeneralRe: How to get a double-click message? Pin
freehawk5-Feb-04 13:41
freehawk5-Feb-04 13:41 
GeneralRe: How to get a double-click message? Pin
_Magnus_5-Feb-04 21:00
_Magnus_5-Feb-04 21:00 
QuestionHow to change title text of dialog in a wtl project? Pin
freehawk4-Feb-04 14:57
freehawk4-Feb-04 14:57 
AnswerRe: How to change title text of dialog in a wtl project? Pin
_Magnus_5-Feb-04 0:12
_Magnus_5-Feb-04 0:12 
GeneralRe: How to change title text of dialog in a wtl project? Pin
freehawk5-Feb-04 13:44
freehawk5-Feb-04 13:44 
Generalgetting linking error Pin
ramyazm4-Feb-04 2:47
ramyazm4-Feb-04 2:47 
Questionhow to create a help file add to a wtl project? Pin
freehawk3-Feb-04 19:21
freehawk3-Feb-04 19:21 
AnswerRe: how to create a help file add to a wtl project? Pin
Douglas Troy6-Feb-04 4:32
Douglas Troy6-Feb-04 4:32 

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.