Jump to content
Software FX Community

RE: How can I create a chart object without ever creating a window to display it (Version 6.2)


Recommended Posts

Dear  support:
We purchased the chartfx client server 5.1. In this version we can write the following code to create a chart object without ever chreating a window to display it.
1. in StdAfx.h file add the following code
// DEFINITION of COM wrappers#import "C:\\Program Files\\Common Files\\Software FX Shared\\sfxbar.dll" no_namespace no_implementation#import "C:\\Program Files\\Common Files\\Software FX Shared\\Cfx4032.dll" no_namespace no_implementation
2. When we create a chartfx object I wrote the following code
 if(m_pChartFX== NULL){ bool bRetry = true;
Retry: if (SUCCEEDED(CoGetClassObject(__uuidof(ChartFX),CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory2,(LPVOID FAR *) &pFactory2))) { if (FAILED(pFactory2->CreateInstanceLic(NULL,NULL,__uuidof(IChartFX), g_sLicenseString, (LPVOID FAR *) &m_pChartFX))) return FALSE ;  pFactory2->Release(); } else{  if(RegisterChartFXdlls()){ // just retry once if(false == bRetry)return FALSE; bRetry = false; goto Retry;  } } }
m_pChartFX is the type of IChartFXPtr in the old version. So by now, the m_pChartFX is initialized and I can call the functions that m_pChartFX provides.
So far so good until we purchased the new version of CharFX client Server 6.2. We wanna upgrade our application to use the new API. The first question is I wanna do the similar way as the codes shown above. After I installed the version 6.2 I found the old chx4032.dll and sfxbar.dll is replaced by ChartFX.ClientServer.Core. dll (is it right?) So I change the code in StdAfx.h as shown below:
#import "C:\Program Files\Common Files\Software FX Shared\ChartFX.ClientServer.Core.dll" rename_namespace("Cfx62") rename("min","minX") rename("max","maxX") exclude("_CollectionBase","_Component","CollectionBase","Component")
2. I changed the old code to obtain a chartFX com object as show below
Retry:// if (SUCCEEDED(CoGetClassObject(__uuidof(ChartFX),CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory2,(LPVOID FAR *) &pFactory2))) { //upgrade if (SUCCEEDED(CoGetClassObject(__uuidof(Cfx62::Chart),CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory2,(LPVOID FAR *) &pFactory2))) { //  if (FAILED(pFactory2->CreateInstanceLic(NULL,NULL,__uuidof(IChartFX),same lisence string as the old purchase,(LPVOID FAR *) &m_pChartFX)))//upgrade XXX  if (FAILED(pFactory2->CreateInstanceLic(NULL,NULL,__uuidof(Cfx62::_Chart),same lisence string as the old purchase,(LPVOID FAR *) &m_pChartFX))) return FALSE ;  pFactory2->Release(); } else{  if(RegisterChartFXdlls()){ // just retry once if(false == bRetry)return FALSE; bRetry = false; goto Retry;  } } }
m_pChartFX now is the type of Cfx62::_ChartPtr
Question is the license string still use the old purchase license string or I should get a new one? How and where can I get the new license string? Does the code shown above can succesfully create a COM object that I could use?
I tried the code above that I can really initialize the m_pChartFX no matter I provide or not provide a license string. Of course the m_pChartFX doesn't work the way that I expect. For example, if I try to export a bitmap file by using m_pChartFX->Export(Cfx62::Fileformat_Bitmap,L"C:\\test.bmp"). it simply doesn't work. The test.bmp file has zero size Nothing is written in it.  But When I export something else like binary format file or xml file, I can get something out. File is not empty.
I know I can get Cfx62::_ChartPtr type object by creating a window the code might look like this

//Create Window Control

m_chartWnd.CreateControl(__uuidof(Cfx62::Chart), NULL, WS_VISIBLE, rc, this, IDC_CHART1, NULL, NULL, NULL /* License String goes here */);

// Attach Window Control to Chart Pointer

m_chartPtr = m_chartWnd.GetControlUnknown();

BSTR bstrLicense = ::SysAllocString(L"LicenseStringGoesHere");


 But I want to create m_charPtr by not creating a window at all like the code we wrote in the old version. How can we achieve this?

Kindly Regards
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...