Jump to content
Software FX Community

Re: Annotation object


User (Legacy)

Recommended Posts

Hi Josh, 

I tried your code but it doesn't work too. The call to raw_GetExtension()

instantly returns the error CO_E_CLASSSTRING (Invalid class string) even if

the extension is already added. So pAnnList is always NULL and, as a result,

2 or more annotate toolbars (and thus annotate extensions) appear on the

chart (instead of single).

From what the error text says I suspect that the problem is with

"AnnotationX.AnnList" string. For some reason raw_GetExtension() doesn't

recognize it as a valid extension name.

Annotatex.dll is registered because AddExtension works and annotation

objects work too.

Serge

"Josh Eanes" <josheanes@bihrle.com> wrote in message

news:DE0379D14694D211B4CE00609770710D05CCE1@sftfx-221.wamnet.net...

> HI Serge,

>

> From what I understand with the getextension call, a failure to return

!NULL

> means it was found. Frank told me a while ago to try and use the

> raw_GetExtension call so that it doesn't return and cause an unhandled

> exception (or something like that- I had an awful time handling the return

> of the GetExtension).

>

> Here is some code that works for me:

>

> The first part will check to see if it already exists. If it does not

> exist, it will create it. Then it places the toolbar onto the window.

>

> IAnnListPtr pAnnList;

> _bstr_t annotation = "AnnotationX.AnnList";

> try

> {

> chartfx->raw_GetExtension(annotation, (IUnknown **) &pAnnList);

> if (pAnnList == NULL)

> {

> pAnnList.CreateInstance(__uuidof(AnnotationX));

> HRESULT rs = chartfx->AddExtension((IUnknown *)pAnnList);

> }

> }

> catch(...)

> {

> pAnnList.CreateInstance(__uuidof(AnnotationX));

> HRESULT rs = chartfx->AddExtension((IUnknown *)pAnnList);

> }

> pAnnList->Enabled = TRUE;

> pAnnList->put_ToolBar(TRUE);

> IToolBar *toolbar;

> pAnnList->get_ToolBarObj(&toolbar);

> toolbar->put_Visible(TRUE);

> toolbar->put_Docked(TGFP_BOTTOM);

>

>

>

> and when I want to remove the extension (and this removes the toolbar

also):

>

> try

> {

> chartfx->raw_GetExtension(annotation, (IUnknown **) &pAnnList);

> }

> catch(...)

> {

> }

> if (pAnnList != NULL) chartfx->raw_RemoveExtension(annotation);

>

>

> HTH

> --

> Josh Eanes

>

>

>

> "Serge S. Spiridonoff" <sss@corbina.net> wrote in message

> news:DE0379D14694D211B4CE00609770710D05BFFF@sftfx-221.wamnet.net...

> > To explain my question in the previous post.

> >

> > I can't get the method GetExtension to work.

> >

> > ...

> > m_pChartFX->AddExtension((IUnknown *)m_pAnnotationList);

> >

> > // for test purposes

> > if (m_pChartFX->GetExtension(_T("AnnotationX.AnnList")) == NULL) {

> > ...

> >

> > In the above code, GetExtension returns an error CO_E_CLASSSTRING

(Invalid

> > class string).

> > I also tried "AnnotateX.AnnList" as suggested by the help but it also

> > returns the same error.

> >

> > AddExtension works fine because the annotation toolbar appears on the

> chart.

> >

> > Why I need to call GetExtension?

> >

> > I call AddExtension just after creation of the chart control

> > (CreateInstanceLic). Then, depending on user selection, I may call the

> > Import() method to load previously saved chart.

> > If the chart being loaded is 3.0 format, then the extension disappears

(no

> > annotate toolbar) after the call to Import().

> > Btw, why?

> > So I need to do AddExtension second time. However, sometimes I get 2

> > annotate toolbars, so I need to check whether the extension is already

> > added.

> >

> > So the question is: how to correctly check that the annotation extension

> is

> > already added to the chart?

> >

> > Thanks,

> > Serge

> >

> >

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...