当firstMember 值为0时,执行两个button函数,这两个函数包括了绘图,返回该按钮是否被点击
但事实上并不会绘图,断点确实经过了,firstMember 为其他值时mciSendString的声音要在非常长的时间(几秒)之后才会发出
if (firstMember == 0) {
if (button(msg, 452, 418, 100, 38, NULL, NULL, WHITE, NULL, "叫地主")) {
numLord ++;
finallord = player;
//叫地主.mp3
//string str;
//mciSendString(str.c_str(), 0, 0, 0);
mciSendString("open audio/男叫地主.mp3 ", 0, 0, 0);
mciSendString("play audio/男叫地主.mp3 ", 0, 0, 0);
}
if (button(msg, 729, 418, 100, 38, NULL, NULL, WHITE, NULL, "不叫")) {
//不叫.mp3
mciSendString("play audio/男不叫.mp3", 0, 0, 0);
}
while (1);
}
else if (firstMember == 1) {
ifLord = rand() % 2;
if (ifLord) {
finallord = bot1;
//叫地主.mp3
mciSendString("play audio/男叫地主.mp3", 0, 0, 0);
Sleep(100);
}
else {
//不叫.mp3
curMember++;
finallord = member::nAn;
mciSendString("play audio/男不叫.mp3", 0, 0, 0);
Sleep(100);
}
}
else if (firstMember == 2) {
ifLord = rand() % 2;
if (ifLord) {
mciSendString("open audio/男叫地主.mp3 ", 0, 0, 0);
mciSendString("play audio/男叫地主.mp3 ", 0, 0, 0);
finallord = bot2;
//叫地主.mp3
Sleep(100);
}
else {
//不叫.mp3
mciSendString("open audio/男不叫.mp3 ", 0, 0, 0);
mciSendString("play audio/男不叫.mp3", 0, 0, 0);
curMember++;
finallord = member::nAn;
Sleep(100);
}
}
while (1);
//button函数
bool button(ExMessage& msg, int posX, int posY, int width, int height, IMAGE* hover,
COLORREF line, COLORREF bg, COLORREF text, LPCTSTR str) {
if (line || bg) {
setlinecolor(line);
setfillcolor(bg);
fillrectangle(posX, posY, posX + width, posY + height);
}
if (str) {
RECT r = { posX,posY,posX + width,posY + height };//左上右下
settextcolor(text);
drawtext(str, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}
int x = msg.x, y = msg.y;
if (x >= posX && x <= posX + width &&
y >= posY && y <= posY + height) {
switch (msg.message) {
case WM_LBUTTONDOWN://鼠标按键动作
if (line || bg) {
setlinecolor(line);
setfillcolor(bg);
fillrectangle(posX + 1, posY + 2, posX + width + 1, posY + height + 2);
}
//模拟按键按下
if (str) {
RECT r = { posX + 1,posY + 2,posX + width + 1,posY + height + 2 };//左上右下
settextcolor(text);
drawtext(str, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}
return true;
break;
case WM_MOUSEMOVE://鼠标移动和鼠标悬停
if (hover != 0) {
transparentimage(NULL, posX, posY, hover);
}
break;
}
}
return false;
}