如何用鼠标滚轮实现绘图窗口的缩放呢

0

在easyX中利用鼠标滚轮实现绘图窗口的缩放

ava
Gezelligheid

2021-12-14

0

可以实现类似缩放效果:

#include <graphics.h>
#include <iostream>
#include <conio.h>

int main()
{
	initgraph(400, 300);

	float xasp = 1;
	float yasp = 1;

	BeginBatchDraw();
	ExMessage msg;
	while (1)
	{
		if (peekmessage(&msg, EM_MOUSE))
		{
			if (msg.message == WM_MOUSEWHEEL)
			{
				if (msg.wheel > 0)
				{
					xasp += 0.1;
					yasp += 0.1;
				}
				else
				{
					xasp -= 0.1;
					yasp -= 0.1;
				}
			}
		}

		setaspectratio(xasp, yasp);
		setbkcolor(BLACK);
		cleardevice();

		setlinecolor(GREEN);
		rectangle(100, 100, 200, 200);
		FlushBatchDraw();

		Sleep(10);
	}

	EndBatchDraw();
	closegraph();
	return 0;
}
ava
xiongfj ◑◑

2021-12-15

技术讨论社区