User (Legacy) Posted July 27, 2000 Report Share Posted July 27, 2000 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 > > Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.