在MFC MS图表控件中,当鼠标在点上时如何查看图表点的值? [英] In MFC MS chart control how to see values of chart points when the mouse is on points?

查看:73
本文介绍了在MFC MS图表控件中,当鼠标在点上时如何查看图表点的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在MFC MS Chart Control中,当鼠标在点上时,如何查看图表点的值?



谢谢。



我尝试过:



在链接 c# - 当鼠标在点上时看到图表点的值 - Stack Overflow [ ^ ],给出c#代码以达到我的要求,但我不知道什么是等价的用于以下c#代码的c ++代码。

chart1.HitTest(pos.X,pos.Y,false,ChartElementType.DataPoint);

Hi,

In MFC MS Chart Control how to see values of chart points when the mouse is on points?

Thanks.

What I have tried:

In the link c# - see values of chart points when the mouse is on points - Stack Overflow[^], c# code is given to achieve my requirement but I dont know what is equivalent code in c++ for the below c# code.
chart1.HitTest(pos.X, pos.Y, false,ChartElementType.DataPoint);

推荐答案

如果在MSDN上检查方法,可以单击C ++选项卡查看该语言的等效项:



Chart.HitTest Method(Int32,Int32,Boolean,ChartElementType [])( System.Windows.Forms.DataVisualization.Charting) [ ^ ]
If you check the method on MSDN, you can click on the C++ tab to see the equivalent in that language:

Chart.HitTest Method (Int32, Int32, Boolean, ChartElementType[]) (System.Windows.Forms.DataVisualization.Charting)[^]


在任何 CWnd 基于类,您可以覆盖 CWnd您的派生类中的:: OnMouseMove

In any CWnd based class you can override CWnd::OnMouseMove in your derived class:
// In CMyClass header file:
//afx_msg void OnMouseMove(UINT nFlags,  CPoint point);

// In CMyClass source file
BEGIN_MESSAGE_MAP(CMyClass, CBaseClass)
    ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()

void CMyClass::OnMouseMove(UINT nFlags, CPoint point)
{
    // Note that this called repeatedly so that execution should
    //  not consume too much time.

    // Add your code here.
    // Check if the CPoint (relative to the upper-left corner if the CWnd)
    //  is on the chart.
    // If so, calculate the value using the proerties of the chart and display them.

    CBaseClass::OnMouseMove(nFlags, point);
}



如果这不适用于MS Chart Control(我从未使用过它),你可以在托管图表的父窗口中捕获鼠标控制(参见上面 CWnd 链接中的 SetCapture()。请注意,这样做会禁用控件的所有鼠标功能。



无论如何,我建议使用可以在Web中找到的许多MFC图表控件实现之一这个古老的控制。


If that does not work with the MS Chart Control (I have never used it), you can capture the mouse in your parent window hosting the chart control (see SetCapture() at the above CWnd link). Note that doing so disables all mouse features of the control.

Anyway, I suggest to use one of the many MFC chart control implementations that can be found in the web instead of this ancient control.


这篇关于在MFC MS图表控件中,当鼠标在点上时如何查看图表点的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆