最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

[C/C++/Easyx]07 消息處理—漂亮的按鈕

2023-08-19 17:26 作者:bili_80498477832  | 我要投稿

交作業(yè)doge, 自己加了點(diǎn)陰影效



#include<stdio.h>

#include<easyx.h>

#include <graphics.h>


ExMessage msg = { 0 };


bool button(int butx, int buty,int butw, int buth , const char* test) {//butx y為按鈕位置


??//繪制按鈕

??setfillcolor(BLACK);//陰影+

??solidroundrect(butx, buty, butx + butw +3, buty + buth+5, 20, 40);//+

??setlinecolor(BLACK);

??setlinestyle(PS_SOLID, 3);

??setfillcolor(RGB(200, 111, 103));

??fillroundrect(butx, buty, butx + butw, buty + buth, 20, 40);


??//繪制文本

??settextcolor(BLACK);

??int hspace = (butw - textwidth(test)) / 2;

??int wspace = (buth - textheight(test)) / 2;

??outtextxy(butx + hspace, buty + wspace, test);


??//鼠標(biāo)在這個(gè)區(qū)域?

??if (msg.x > butx && msg.x < butx + butw && msg.y > buty && msg.y < buty + buth) {

????setfillcolor(RED);

????fillroundrect(butx, buty, butx + butw, buty + buth, 20, 40);

??}


??//鼠標(biāo)在這個(gè)區(qū)域并且單機(jī)了左鍵?

??if (msg.message==WM_LBUTTONDOWN && msg.x > butx && msg.x < butx + butw && msg.y > buty && msg.y < buty + buth) {

????return true;

??}

??return false;???

}

int main() {


??//建立窗口

??initgraph(640, 480, EX_SHOWCONSOLE );

??setbkcolor(RGB(242, 222, 189));

??cleardevice();

??setbkmode(TRANSPARENT);//設(shè)置文字背景透明


??//

??while (true) {

????if (peekmessage(&msg, EX_MOUSE)) {//獲取鼠標(biāo)信息+

????}

????BeginBatchDraw();//

????if (button(180, 300, 100, 50, "Play")) {//x, y, wide, heigh, text

??????printf("Game Start\n");

????}

????if (button(380, 300, 100, 50, "Quit")) {//x, y, wide, heigh, text

??????printf("Closing...\n");

????}

????EndBatchDraw();

????msg.message = 0;

??}


??//保持顯示

??getchar();

??closegraph();

??return 0;

[C/C++/Easyx]07 消息處理—漂亮的按鈕的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
偃师市| 泰安市| 安新县| 香河县| 天峻县| 商南县| 淮阳县| 泰顺县| 绥德县| 开封市| 柞水县| 三门县| 高雄县| 翁源县| 瑞昌市| 大城县| 安西县| 苍南县| 北辰区| 莒南县| 马尔康县| 凉城县| 永嘉县| 柳林县| 和林格尔县| 麻城市| 壤塘县| 屯门区| 香河县| 伊川县| 延长县| 竹北市| 高阳县| 章丘市| 阜宁县| 闻喜县| 勃利县| 家居| 八宿县| 广东省| 木兰县|