I have attached CWGraph control into my dialog, created member variable pointer with the same class and then try to get the object with AttachControlSite(this, IDC_GRAPH1). Since I could not get the handle with:
CNiGraph graph;
graph.AttachControlSite(this, IDC_GRAPH1); // this resulted in graph being NULL
I tried this:
CNiGraph* p_graph;
p_graph = (CNiGraph*)GetDlgItem(IDC_GRAPH1); // CWnd is NULL, but I'm getting NI::CNiControl with this call and CWnd is part of it
p_graph->AttachControlSite(this, IDC_GRAPH1); // This doesn't change anything
This call fails naturally since CWnd is not initialized:
m_pCalGraph->PlotXY(fr, (dPwrLvl*-1) - 10);
"Unhandled exception at 0x78244515 (mfc80d.dll) in foo.exe: 0xC0000005: Access violation reading location 0x0000009c."
In afxstate.cpp where pNewState in NULL.
if (AfxGetAmbientActCtx() &&
pNewState->m_hActCtx != INVALID_HANDLE_VALUE)