如下代码,在点击窗口的同时拖动鼠标,会不断触发lbutton的左键事件,即使已经清空了
提供一个复现的方法,在窗口内边移动鼠标边点击左键,会发现输出次数明显高于实际点击次数
请问是我的写法有问题吗
#include<easyx.h>
#include <iostream>
using namespace std;
int main()
{
initgraph(1000, 600);
ExMessage message={};
int x = 0;
while (true)
{
//如果有新消息
if (peekmessage(&message))
{
//处理一次
if (message.lbutton)
{
cout << ++x<<endl;
}
//清空
message = {};
flushmessage();
}
}
closegraph();
}
请问和win的消息队列有关吗?是否是我更新的太快而消息仍然存在于win的消息队列里