Click here to Skip to main content
15,891,645 members
Home / Discussions / COM
   

COM

 
AnswerRe: Launching multiple IE Pin
Jörgen Sigvardsson13-Jun-08 10:49
Jörgen Sigvardsson13-Jun-08 10:49 
GeneralRe: Launching multiple IE Pin
Nirav Doshi13-Jun-08 20:14
Nirav Doshi13-Jun-08 20:14 
GeneralRe: Launching multiple IE Pin
Jörgen Sigvardsson13-Jun-08 22:14
Jörgen Sigvardsson13-Jun-08 22:14 
GeneralRe: Launching multiple IE Pin
Nirav Doshi14-Jun-08 2:06
Nirav Doshi14-Jun-08 2:06 
QuestionDetect Network Adapters in Borland C++ Builder Pin
Nekt Chrono4-Jun-08 21:54
Nekt Chrono4-Jun-08 21:54 
QuestionExcel WorkbookBeforeClose event Document Proof Pin
HarishKumarS4-Jun-08 4:37
HarishKumarS4-Jun-08 4:37 
Questionpass a parameter to a com+ application Pin
Ayman Mashal4-Jun-08 0:19
Ayman Mashal4-Jun-08 0:19 
QuestionCOM and Inteface/Implementation Polymorphism Pin
kimutley3-Jun-08 10:02
kimutley3-Jun-08 10:02 
Hi all.

This is my 1st post to the Code Project so please excuse me if I step on some toes.

My question relates to polymorphism (I'm using VS 8.0 with ATL/COM). Assume the following (off the top of my head). What I want to do is to have a ITestOne interface with CTestOne implemented and a ITestTwo interface with CTestTwo implemented. I want to use ITestTwo to access ITestTwo interface implementations and to access ITestOne Interface implementations. I will have other classes derived from ITestTwo (e.g., ITestThree, ITestFour) and CTestThree derived from CTestTwo, etc.

Any suggestions???

TIA,

Kim

[
object,
uuid(F799607A-47E7-4582-B056-9FD4F5381BA5),
helpstring("ITestOne Interface"),
pointer_default(unique)
]
interface ITestOne : IUnknown{
};
[
object,
uuid(9AE009F8-99D9-4C4A-B0BC-9A34EEFCF78B),
helpstring("ITestTwo Interface"),
pointer_default(unique)
]
interface ITestTwo : IUnknown{
};
[
uuid(B7AB057E-F270-4019-966F-52E9994F82C2),
version(1.0),
helpstring("COMTest 1.0 Type Library")
]
library COMTestLib
{
importlib("stdole2.tlb");
[
uuid(F019A63E-D8ED-463B-AB5F-996A9231E448),
helpstring("TestOne Class")
]
coclass TestOne
{
[default] interface ITestOne;
};
[
uuid(31E6DA9C-DE0D-4B69-A259-1D39E136D31F),
helpstring("TestTwo Class")
]
coclass TestTwo
{
[default] interface ITestTwo;
};
};

Now I want to _really_ derive ITestTwo from ITestOne so both interfaces will be available in ITestTwo. To do this I change the following:

From: interface ITestTwo : IUnknown {};
To: interface ITestTwo : ITestOne

So far so good???... If so I then should be able to do the following (I only added the TestOneInterface() function to existing code generated by VS):

/**** CTestTwo Declarations ****/

class ATL_NO_VTABLE CTestOne : public CTestTwo
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<ctestone, clsid_testone="">,
public ISupportErrorInfo,
public ITestOne
{
public:
CTestOne()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_TESTONE)


BEGIN_COM_MAP(CTestOne)
COM_INTERFACE_ENTRY(ITestOne)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct()
{
return S_OK;
}

void FinalRelease()
{
}

public:

/**** CTestOne Implementations ****/
STDMETHOD(TestOneInterface)( void ) { }

};

OBJECT_ENTRY_AUTO(__uuidof(TestOne), CTestOne)


/**** CTestTwo Declarations ****/

class ATL_NO_VTABLE CTestTwo :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CTestTwo, &CLSID_TestTwo>,
public ITestTwo
{
public:
CTestTwo()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_TESTTWO)


BEGIN_COM_MAP(CTestTwo)
COM_INTERFACE_ENTRY(ITestTwo)
END_COM_MAP()



DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct()
{
return S_OK;
}

void FinalRelease()
{
}

public:

/**** CTestTwo Implementations ****/
STDMETHOD(TestTwoInterface)( void ) { }

};

OBJECT_ENTRY_AUTO(__uuidof(TestTwo), CTestTwo)
Questionc# delegates and effect on c++ com server Pin
dtranter3-Jun-08 1:06
dtranter3-Jun-08 1:06 
QuestionGetting the Physical File Name of a Spreadsheet Pin
Brendan Vogt2-Jun-08 1:06
Brendan Vogt2-Jun-08 1:06 
AnswerRe: Getting the Physical File Name of a Spreadsheet Pin
Vi26-Jun-08 0:24
Vi26-Jun-08 0:24 
QuestiondirectX with webcam Property Pin
mmvv2-Jun-08 0:06
mmvv2-Jun-08 0:06 
QuestionCoInitialize permissions for windows service Pin
rana741-Jun-08 19:12
rana741-Jun-08 19:12 
AnswerRe: CoInitialize permissions for windows service Pin
rana742-Jun-08 16:04
rana742-Jun-08 16:04 
GeneralRe: CoInitialize permissions for windows service Pin
vipin.vjayan6-Oct-20 4:04
vipin.vjayan6-Oct-20 4:04 
QuestionHow to make the ActiveX control full transparent in word Pin
liuguang1-Jun-08 17:01
liuguang1-Jun-08 17:01 
QuestionUsing IFileOpenDialog in C# Pin
jonesap530-May-08 5:49
jonesap530-May-08 5:49 
AnswerRe: Using IFileOpenDialog in C# Pin
Mike Dimmick2-Jun-08 7:09
Mike Dimmick2-Jun-08 7:09 
AnswerRe: Using IFileOpenDialog in C# Pin
capcom92319-Jul-11 22:25
capcom92319-Jul-11 22:25 
QuestionProblem with COM objects used to replicate data from lotus notes to SQL Pin
madhuGM29-May-08 6:06
madhuGM29-May-08 6:06 
Questionhow selective loading BHO in Chtmlview environment Pin
ftbk27-May-08 16:29
ftbk27-May-08 16:29 
Answer[Cross Post]Re: how selective loading BHO in Chtmlview environment Pin
Scott Dorman27-May-08 17:24
professionalScott Dorman27-May-08 17:24 
QuestionCompiling a VC++ 6.0 project with VC++ 7.1 problem: Error C2664 with CComPtr. Please help. Pin
Arris7426-May-08 3:19
Arris7426-May-08 3:19 
AnswerRe: Compiling a VC++ 6.0 project with VC++ 7.1 problem: Error C2664 with CComPtr. Please help. Pin
Mike Dimmick28-May-08 7:20
Mike Dimmick28-May-08 7:20 
QuestionOLE Compound Document - File Drag Drop Pin
sunil_963125-May-08 23:36
sunil_963125-May-08 23:36 

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.