有谁可以写一个鼠标离开绘图窗口,绘制提示信息的程序

0

有谁可以写一个鼠标离开绘图窗口,绘制提示信息的程序

ava
whoami

2023-3-26

0
#include <iostream>
#include <graphics.h>
#include <windows.h>

int main()
{
	initgraph(500, 500);
	while (true)
	{
		POINT pt;
		if (GetCursorPos(&pt))
		{
			HWND hWnd = GetHWnd();
			RECT rt;
			if (GetWindowRect(hWnd, &rt))
			{
				cleardevice();
				if (PtInRect(&rt, pt))
				{
					outtextxy(100, 250, L"在屏幕内");
				}
				else
				{
					outtextxy(100, 250, L"在屏幕外");
				}
			}
		}
		Sleep(33);
	}
	closegraph();
	return 0;
}
ava
喵爪

2023-3-26

技术讨论社区