User (Legacy) Posted August 7, 2003 Report Share Posted August 7, 2003 Hi everybody, I would like to know if we can put a chartfx control in a thread because I do so but I have a problem. The graph is plotting itself and then every lines dissapears. Is there any issues with thread with ChartFX ? This is what I've done to put chartFX in thread. 1. Put those lines in the .h file to create the thread static UINT ThreadFunc(LPVOID pvParam);//thread function CWinThread *pThread; //the thread 2. Create a structure in the .cpp file struct ThreadDataTest { CTestSDIDoc *pDoc1; //pointer to the active document HWND hWnd; //Pass CWnd objects by HWND test *testPtr; //pointer to the dialog }; 3, Create the function ThreadFunc UINT test::ThreadFunc(LPVOID pvParam) { ThreadDataTest *td = static_cast<ThreadDataTest *>(pvParam); td->testPtr->m_pChartFX2->Gallery=CURVE; ... //code to plot a graph delete td; //free allocated memory for the structure return 0; } 4. Call the thread ThreadDataTest *td = new ThreadDataTest; td->pDoc1 = CTestSDIDoc::GetDoc(); td->hWnd=GetSafeHwnd(); td->testPtr=this;//this is the current object pThread = AfxBeginThread(ThreadFunc,(LPVOID)td) ;//start the thread In addition to this, I have created 2 chart with those lines in .h and .cpp files CWnd m_ChartFX,m_ChartFX2; IChartFXPtr m_pChartFX,m_pChartFX2; // ***CFX*** // Do not use class wizard to generate these. It will cause the generation of unecesary classes DDX_Control(pDX, IDC_CHART1, m_ChartFX); if (!pDX->m_bSaveAndValidate) // Link Chart FX pointer to control window m_pChartFX = m_ChartFX.GetControlUnknown(); DDX_Control(pDX, IDC_CHART2, m_ChartFX2); if (!pDX->m_bSaveAndValidate) // Link Chart FX pointer to control window m_pChartFX2 = m_ChartFX2.GetControlUnknown(); // ***CFX*** Thanks a lot, Ren Link to comment Share on other sites More sharing options...
Software FX Posted August 8, 2003 Report Share Posted August 8, 2003 Like most ActiveX controls, Chart FX threading model is Apartment. This means that only ONE thread ca access ONE chart object (the thread that created it), multiple threads can have pointer to different chart but you CAN NOT interact with the same chart from two different threads. -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.