简体   繁体   English

VC ++ MFC应用程序无法记录鼠标数值坐标

[英]VC++ MFC application cant log mouse numerical coordinates

Im new to MFC and Im trying to create a quick application on windows to simulate a hardware/computer peripheral that I will later integrate with, when its available,however the hardware will send screen x & y coordinates. 我是MFC的新手,我试图在Windows上创建一个快速应用程序,以模拟我将在以后集成的硬件/计算机外围设备,当它可用时,但硬件将发送屏幕x和y坐标。

I created a MFC application that captures mouse events & on mouse move event. 我创建了一个MFC应用程序,捕获鼠标事件和鼠标移动事件。

I'm able to capture the mouse move events, however the log does NOT show a numerical value for X & Y and instead outputs .cpp file path for X's value & and nothing for Y, strange? 我能够捕获鼠标移动事件,但是日志不会显示X和Y的数值,而是输出.cpp文件路径获取X的值&而且没有Y,奇怪吗?

See code snippet below: 请参阅下面的代码段:

  void CRingExampleView::OnMouseMove(UINT nFlags, CPoint point)
{
    // TODO: Add your message handler code here and/or call default
    /*
    I also tried declaring a new point POINT p and passing that to GetCursorPos(&p), but still now numerical output
    */
    if (GetCursorPos(&point))
    {

        TRACE("X:", point.x);
        TRACE("Y:", point.y);

    }

    CScrollView::OnMouseMove(nFlags, point);
}

        CScrollView::OnMouseMove(nFlags, point);
    }//end function 

See the screenshot for log and the app: 查看日志和应用程序的屏幕截图:

在此输入图像描述

How can I output the numerical x & y values? 如何输出数值x和y值?

Thanks 谢谢

The problem is that your TRACE statement needs a format string. 问题是您的TRACE语句需要格式字符串。

EXAMPLE: 例:

 TRACE(_T("X: %d"), point.x);

You can read more here: 你可以在这里阅读更多:

MFC Debugging Techniques MFC调试技术

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM