Re: API troulble

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Based on your reply, I'm not sure you really want all that hassle. Yes,
you could use CLSIDFromProgID and create your objects from Automation
clients. But if you just want to have multiple document types, the
standard MFC document/view architecture provides all the means necessary
to select File | New from the menu, choose a document type, and let the
MFC framework create your document, view, and frame window.

If you just want data classes to be embedded within your normal
document, you don't want to derive them from CDocument at all, probably.
Just derive them from CObject, maybe, or perhaps have no base class.

In article <42c26baa$0$4166$9a6e19ea@xxxxxxxxxxxxxxxxxxxxxxxxx>,
ContactGT_remove_@xxxxxxxxxxx says...
> Thanks for the tip - I'll look into those methods on MSDN.
>
> It wasn't my choice not to just use normal constructors. I created the
> classes through the class wizard and ticked 'automation' and it made the
> constructors protected and didn't add a method allowing me to instantiate
> objects! I presumed there was a reason for this, so didn't like to move
> things around!
>
> My test application just sees the interfaces, so there needs to be a method
> to get/create new instances of the classes. As with linking to Excel, the
> application is instantiated, then you ask for the group of workbooks, from
> that group of workbooks, there is a method to create a new workbook. I need
> something along these lines (I think), I just don't know how to create
> objects!
>
>
>
> "Scot T Brennecke" <ScotBspamhater@xxxxxxxx> wrote in message
> news:MPG.1d2c0cda17edcc2c989c4d@xxxxxxxxxxxxxxxxxxxxxxx
> > Do I understand correctly that you want to create COM interfaces for
> > your classes, rather than just calling C++ constructors and class
> > methods directly? If so, you will want to use something like
> > CoCreateInstance to instantiate your COM objects, then QueryInterface
> > for these new interfaces.
> >
> > In article <42c12483$0$26767$9a6e19ea@xxxxxxxxxxxxxxxxxxxxxxxxx>,
> > ContactGT_remove_@xxxxxxxxxxx says...
> >> Writing an API for my application and I have a problem. I have an
> >> interface
> >> class for my normal document, but I want to create a few new interfaces
> >> IDoc
> >> IPerson ITeam etc...
> >>
> >> I create a new class "CTeam" choose CDocument for its base class and
> >> choose
> >> 'automation' and hey presto I get a new ITeam interface. How do I then
> >> create an instance of CTeam because its constructor is protected and it
> >> uses
> >> DECLARE_DYNCREATE, which is also protected.
> >>
> >> In my mini-app I have written to test the API on my main app, I cannot
> >> create an instance of ITeam because I just get NULL references!
> >>
> >> Basically, how do I use my new class???
.



Relevant Pages

  • Re: [RFC PATCH 00/17] virtual-bus
    ... How would the interfaces to the user look like? ... So a sufficiently privileged user can instantiate a new bus (e.g. ... So now imagine we have some kind of disk-io vbus device that is designed ... So the admin would instantiate this "vdisk" device and do: ...
    (Linux-Kernel)
  • Re: on the strange weakness of Graphical User Interface Languages
    ... The situation we currently have is that computers and their UIs ... user interfaces, as I expect no one would find surprising. ... world combines some automation with other more familiar elements. ...
    (comp.lang.lisp)
  • Re: Dynamic Class loading and if () statements
    ... >> This may pose a problem. ... The interfaces are always included in the ... You program can load and instantiate any optional classes ...
    (comp.lang.java.help)
  • Re: API troulble
    ... It wasn't my choice not to just use normal constructors. ... My test application just sees the interfaces, so there needs to be a method ... > CoCreateInstance to instantiate your COM objects, ...
    (microsoft.public.vc.mfc)
  • Re: Looking for COM class that has methods with output parameters
    ... interface as and call it from an Automation environment like ... interfaces, but VB6 can also call non-dual Automation-compatible ... Microsoft MVP, MCSD ... Are you saying that methods that have parameters do not free the ...
    (microsoft.public.win32.programmer.ole)