#include <graphics.h>
#include <stdio.h>

void main()
{
    initgraph(640, 480);        // 初始化绘图窗口
    HWND hwnd = GetHWnd();        // 获取绘图窗口句柄

    POINT point;
    TCHAR s[10];

    while(true)
    {
        GetCursorPos(&point);            // 获取鼠标指针位置(屏幕坐标)
        ScreenToClient(hwnd, &point);    // 将鼠标指针位置转换为窗口坐标

        // 获取鼠标按键状态可以用 GetAsyncKeyState 函数,这里不再详述。

        // 输出鼠标坐标
        sprintf(s, _T("%05d"), point.x);
        outtextxy(0, 0, s);

        sprintf(s, _T("%05d"), point.y);
        outtextxy(0, 20, s);

        // 适当延时
        Sleep(10);
    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2021-11-07
  • 2021-11-07
  • 2021-11-07
  • 2022-01-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-02-18
  • 2021-12-23
  • 2021-10-11
相关资源
相似解决方案