Software FX Posted July 27, 2000 Report Share Posted July 27, 2000 Our code will first invoke the CLSIDFromProgID COM API that translates a ProgID (such as "AnnotationX.AnnList") into a CLASSID. If this code fails we will return its return value. According to the Windows API CO_E_CLASSSTRING: The registered CLSID for the ProgID is invalid. You may also want to try "AnnotationX.AnnList.1" and check your registry to see if this PROGID is in the HKEY_CLASSES_ROOT hive. Please note that if you are using the ChartFX ActiveX control the parameter should be a BSTR, if you are using the ChartFX DLL it should be an LPSTR. Regards, Juan Cegarra Software FX, Inc. http://support.softwarefx.com -----Original Message----- From: Serge S. Spiridonoff [ mailto:sss@corbina.net] Posted At: Thursday, July 27, 2000 4:49 PM Posted To: General Conversation: Annotation object Subject: Re: Annotation object 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.