簡體   English   中英

VC ++ MFC應用程序無法記錄鼠標數值坐標

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

我是MFC的新手,我試圖在Windows上創建一個快速應用程序,以模擬我將在以后集成的硬件/計算機外圍設備,當它可用時,但硬件將發送屏幕x和y坐標。

我創建了一個MFC應用程序,捕獲鼠標事件和鼠標移動事件。

我能夠捕獲鼠標移動事件,但是日志不會顯示X和Y的數值,而是輸出.cpp文件路徑獲取X的值&而且沒有Y,奇怪嗎?

請參閱下面的代碼段:

  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 

查看日志和應用程序的屏幕截圖:

在此輸入圖像描述

如何輸出數值x和y值?

謝謝

問題是您的TRACE語句需要格式字符串。

例:

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

你可以在這里閱讀更多:

MFC調試技術

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM