I have MFC project, which has two chart on dialog window.
I am trying to synchronize cursor movement between those two charts. So when I move cursor over one chart, second chart tracks this mouse movement and have its cursor follow same path. I use custom cursor. Not the system arrow. Same about axis. Once I update axis for one of them, second should be updated in the same way. So far no luck.
So obviously onMouseMove should be somehow utilize here. Coordinate and axises settings from one chart should transferred to the second one once they are changed.
Was not able to find any good example on similar case.
To add chart to Dialog window I updated CMyDlg rc with "custom control", set the Class field to "CMyChart", ID to "IDC_CHART_TOP". Did similar for bottom chart.
please find some simplified version of my code.
//// CMyDlg.cpp ////
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CHART_TOP, m_ChartTop);
DDX_Control(pDX, IDC_CHART_BOTTOM, m_ChartBottom);
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
END_MESSAGE_MAP()
void CMyDlg::plotDataTop()
{
// init and plot m_ChartTop
}
void CMyDlg::plotDataBottom()
{
// init and plot m_ChartBottom
}
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
plotDataTop();
plotDataBottom();
return TRUE;
}
//// MyDlg.h ////
class CMyDlg : public CDialog
{
public:
CMyDlg(CWnd* pParent = nullptr);
virtual ~CMyDlg();
#ifdef AFX_DESIGN_TIME
enum { IDD = DLG_MYDLG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
CMyChart m_ChartTop;
CMyChart m_ChartBottom;
public:
// plot data
void plotDataTop();
void plotDataBottom();
};