Click here to Skip to main content
15,912,578 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionHow to get clipping region of windowless activex? Pin
smalti1-Dec-09 9:15
smalti1-Dec-09 9:15 
QuestionError on using BMP image in LoadBitmap Pin
am 200926-Nov-09 0:47
am 200926-Nov-09 0:47 
AnswerRe: Error on using BMP image in LoadBitmap Pin
KingsGambit29-Nov-09 19:16
KingsGambit29-Nov-09 19:16 
QuestionHow to control IWMPPlayer? Pin
kcynic25-Nov-09 16:30
kcynic25-Nov-09 16:30 
QuestionNo Keyboard Support for ActiveX Controls in WIN32 App Pin
hZenz23-Nov-09 0:12
hZenz23-Nov-09 0:12 
QuestionHow to implement a multi-column menu? Pin
hawkgao012919-Nov-09 21:00
hawkgao012919-Nov-09 21:00 
AnswerRe: How to implement a multi-column menu? Pin
hawkgao012919-Nov-09 21:58
hawkgao012919-Nov-09 21:58 
QuestionExposing methods via a COM object Pin
mbet87817-Nov-09 22:24
mbet87817-Nov-09 22:24 
Hello together,

may be this is a simple question. But I am missing a piece to put it all together. I have searched for patterns how to use COM in real life, but nothing told me that. I know how to implement interfaces, properties and methods and so on.
So here is what I want to do.

I have a normal C++ object from a class like CSomeObject. This class implements a bunch of methods. Now I want to use this methods not only in the program itself but also in the outside world. So I put all the methods I want to use in a normal interface.

class CSomeObject : public ICommandProvider
{
...
};

class ICommandProvider
{
public:
void Command1();
void Command2(int arg);
};

Then I want to create a CoClass offering an interface like ICommandProvider, let's name the COM interface ICommands.

interface ICommands : IDispatch
{
HRESULT Command1();
HRESULT Command2([in] int arg);
};

And the COM object is implemented using the ATL framework. The COM object should have a private pointer to the normal ICommandProvider interface.

class ATL_NO_VTABLE CoCommands :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CoCommands, &CLSID_CoCommands>,
public IDispatchImpl<ICommands, &IID_ICommands, &LIBID_MyLib>
{
public:
CoCommands();
...
private:
ICommandProvider *m_pCommandProvider;
};

Now it comes to my problem. I don't know how to set up the pointer.
I can't do it in the constructor, because one need a default constructor to create a COM object using the CreateInstance methods.
May be a solution is to implement another COM interface to set up the private pointer. But this sounds like overhead I don't need, right?
So what is the normal pattern to set up a COM object with the internal data it should offer to some client?

Best regards!
AnswerRe: Exposing methods via a COM object Pin
Jonathan Davies18-Nov-09 7:42
Jonathan Davies18-Nov-09 7:42 
AnswerRe: Exposing methods via a COM object Pin
Lim Bio Liong18-Nov-09 22:59
Lim Bio Liong18-Nov-09 22:59 
AnswerRe: Exposing methods via a COM object Pin
mbet87825-Nov-09 23:09
mbet87825-Nov-09 23:09 
QuestionHow to prevent Quicksort stack overflow? Pin
crazy6612-Nov-09 6:21
crazy6612-Nov-09 6:21 
AnswerRe: How to prevent Quicksort stack overflow? Pin
Richard MacCutchan12-Nov-09 9:14
mveRichard MacCutchan12-Nov-09 9:14 
QuestionERROR - Object deleted before window was destroyed Pin
kcynic12-Nov-09 1:23
kcynic12-Nov-09 1:23 
AnswerRe: ERROR - Object deleted before window was destroyed Pin
Stuart Dootson12-Nov-09 5:03
professionalStuart Dootson12-Nov-09 5:03 
GeneralRe: ERROR - Object deleted before window was destroyed Pin
kcynic12-Nov-09 14:00
kcynic12-Nov-09 14:00 
GeneralRe: ERROR - Object deleted before window was destroyed Pin
kcynic12-Nov-09 23:45
kcynic12-Nov-09 23:45 
QuestionATL Exe Service Pin
Anthony988710-Nov-09 3:45
Anthony988710-Nov-09 3:45 
QuestionRe: ATL Exe Service Pin
ChrisSieben1-Dec-09 3:58
ChrisSieben1-Dec-09 3:58 
QuestionWTL Custom message handling in the message map? [modified] Pin
Member 38198215-Nov-09 23:13
Member 38198215-Nov-09 23:13 
AnswerRe: WTL Custom message handling in the message map? Pin
KingsGambit9-Nov-09 9:03
KingsGambit9-Nov-09 9:03 
QuestionHow to change button color in ATL Pin
am 20094-Nov-09 20:08
am 20094-Nov-09 20:08 
AnswerRe: How to change button color in ATL Pin
«_Superman_»5-Nov-09 8:24
professional«_Superman_»5-Nov-09 8:24 
QuestionHow to access custom ActiveX object properties in ATL Composite Control Pin
komofilms774-Nov-09 19:52
komofilms774-Nov-09 19:52 
QuestionHow to remove type library informationn from atl dll? Pin
kcynic4-Nov-09 15:33
kcynic4-Nov-09 15: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.