#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <time.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#include<assert.h>
#include<easyx.h>
#define ture 1
#define false 0
bool isInButton(ExMessage* m, int x, int y, int w, int h)
{
if (m->x > x && m->x<x + w && m->y>y && m->y < y + h)
{
return ture;
}
return false;
}
//鼠标点击
int main()
{
int which = 0;
ExMessage m;
initgraph(960,580,EX_SHOWCONSOLE);
while (1)
{
//处理消息,不断获取鼠标消息,如果有消息返回ture,否则返回false
if (peekmessage(&m,EX_MOUSE))
{
switch (m.message)
{
case WM_LBUTTONDOWN:
if (isInButton(&m,433,515,314,101))
{
which++;
printf("%d",which);
}
default:
break;
}
}
}
getchar();
return 0;
}
举报
请问一下,为什么鼠标点击这个区域不能运行,就是不能显示which的数值
举报
你的代码逻辑上并没有问题,main 后面的括号用成全角了。