caller.
any userdefined class.
"Tony Johansson" <johansson.andersson@telia.com> ha scritto nel messaggio
news:FYg_k.4611$U5.34405@newsb.telia.net...
I'm almost 100 % sure that in my class Handle_DS I have two methods that
is defined
as public and in the idl file where the IHandle_DS is defined I have
defined
the same methods.
So when I try to access fields in the Interface IHandle_DS it will cause
compile error despite
having several fields in this Handle_DS coclass.
I don't know what you mean by "fields"... Do you mean the interface
methods?
If you have the C++ class CHandle_DS which exposes say a public field
like "int m_Something", you *can't* access it from a client using the
IHandle_DS interface pointer.
So If I just want to add a new class with its interface to the COM is
the right way to use
insert and then new class and then I choose ATL class.on the VS 6.0
menu.
So how would you create a new class(coclass) with its interface in the
COM project ?
I have read the tutorial and it was pretty good.
If you follow the tutorial, you will be able to accomplish the task.
Maybe you are trying to add code "by hand", but probably you don't have
enough COM/ATL knowledge to do so. So, better trusting the VC6 wizard,
and let it creates the infrastructure code, so you can just fill in the
method body.
If you use the wizard and select "Add method", it will add code in the
IDL file like this:
interface ICHandleDS : IDispatch{
[id(1), helpstring("method DoSomething")] HRESULT DoSomething(void);
then it will add a public method in the C++ class header file like this:
public:
...
STDMETHOD(DoSomething)(void);
and it will prepare the skeleton of the method in the C++ class
implementation file like this:
STDMETHODIMP CCHandleDS::DoSomething(void)
{
// TODO: Add your implementation code here
return S_OK;
}
IMHO, you should allocate some time to get better understanding of COM
and ATL; you should carefully read and practice with the tutorials I
posted.
COM is not trivial (it's not like Visual Basic or WinForm that you
drag-and-drop something from a palette of controls and get some visible
results); *using* available COM components is not particularly difficult,
but you have to study if you want to *build* your own COM components.
Giovanni