> 文章列表 > 项目制作-3

项目制作-3

项目制作-3

今天是好日子呀解决了

文件的问题(未测试)

完成了更多的界面的设计

对基本的模块有了更多的完成度

又学习了easyx图形库的一些的应用

一起来看看吧

void menu() {initgraph(640, 800, 0);IMAGE img;loadimage(&img, "C:\\\\Users\\\\唐怡佳\\\\Desktop\\\\图1.jpg", 640, 800);while(1){BeginBatchDraw();putimage(0, 0, &img);setfillcolor(YELLOW);char a[20] = "地图全貌";char b[20] = "查询路线";char c[20] = "公告板";char d[20] = "管理入口";char e[10] = "退出";settextstyle(50, 0, "楷书");setbkmode(TRANSPARENT);settextcolor(BLACK);fillrectangle(120, 150, 520, 250);int x1 = 120 + (400 - textwidth(a)) / 2;int y1 = 150 + (100 - textheight(a)) / 2;outtextxy(x1, y1, a);fillrectangle(120, 300, 520, 400);int x2 = 120 + (400 - textwidth(b)) / 2;int y2 = 300 + (100 - textheight(b)) / 2;outtextxy(x2, y2, b);fillrectangle(120, 450, 520, 550);int x3 = 120 + (400 - textwidth(c)) / 2;int y3 = 450 + (100 - textheight(c)) / 2;outtextxy(x3, y3, c);fillrectangle(120, 600, 520, 700);int x4 = 120 + (400 - textwidth(d)) / 2;int y4 = 600 + (100 - textheight(d)) / 2;outtextxy(x4, y4, d);fillrectangle(340, 700, 640, 800);int x5 = 340 + (300 - textwidth(e)) / 2;int y5 = 700 + (100 - textheight(e)) / 2;outtextxy(x5, y5, e);FlushBatchDraw();MOUSEMSG msg;if (MouseHit()) {msg = GetMouseMsg();if (msg.uMsg == WM_LBUTTONDOWN) {if (msg.x >= 120 && msg.x <= 520 && msg.y >= 150 && msg.y <= 250) {};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 300 && msg.y <= 400) {};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 450 && msg.y <= 550) {};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 600 && msg.y <= 700) {char p[50];InputBox(p, 50, "请输入密码");if (strcmp(p, password) == 0)mastermenu();else {HWND hwnd = GetHWnd();SetWindowText(hwnd, "提示");int i = MessageBox(hwnd, "密码错误", "提示", MB_OK);}};if (msg.x >= 340 && msg.x <= 640 && msg.y >= 700 && msg.y <= 800) {tuichu();};}}}}//菜单(未完成)

把昨天做的界面放到了,项目里面,由于有界面的切换,我搞了一个双缓冲的 

BeginBatchDraw();

以及结束的

FlushBatchDraw();

是关于缓存区的函数,我暂时还不明白

InputBox(p, 50, "请输入密码");if (strcmp(p, password) == 0)mastermenu();else {HWND hwnd = GetHWnd();SetWindowText(hwnd, "提示");int i = MessageBox(hwnd, "密码错误", "提示", MB_OK);}

intputbox是输入框,用字符串变量接收就可以,对密码进行一个判断了

HWND hwnd = GetHWnd();//申请窗口的句柄

SetWindowText(hwnd, "提示");//给窗口一个标题

MessageBox(hwnd, "密码错误", "提示", MB_OK);//窗口的信息,以及模式

这是一个只可以点确定的弹出窗口

MOUSEMSG msg;//申请一个鼠标的变量if (MouseHit()) {//判断是否有鼠标点击msg = GetMouseMsg();//捕获这个点击信息给msgif (msg.uMsg == WM_LBUTTONDOWN) {//判断是否是鼠标的左键

我本来用的新版的,但是老是出文题就用老板的了 

msg.x和msg.y是当前的鼠标信息点击的像素的位置

我还完成了,管理员的界面

void mastermenu() {IMAGE img1;loadimage(&img1, "C:\\\\Users\\\\唐怡佳\\\\Desktop\\\\图2.jpg", 640, 800);while (1) {BeginBatchDraw();putimage(0, 0, &img1);char a[20] = "公告版的管理";char b[20] = "景区景点的录入";char c[20] = "景区景点的删除";char d[20] = "管理员密码的修改";char e[10] = "退出";settextstyle(50, 0, "行书");setbkmode(TRANSPARENT);settextcolor(BLACK);fillrectangle(120, 150, 520, 250);int x1 = 120 + (400 - textwidth(a)) / 2;int y1 = 150 + (100 - textheight(a)) / 2;outtextxy(x1, y1, a);fillrectangle(120, 300, 520, 400);int x2 = 120 + (400 - textwidth(b)) / 2;int y2 = 300 + (100 - textheight(b)) / 2;outtextxy(x2, y2, b);fillrectangle(120, 450, 520, 550);int x3 = 120 + (400 - textwidth(c)) / 2;int y3 = 450 + (100 - textheight(c)) / 2;outtextxy(x3, y3, c);fillrectangle(120, 600, 520, 700);int x4 = 120 + (400 - textwidth(d)) / 2;int y4 = 600 + (100 - textheight(d)) / 2;outtextxy(x4, y4, d);fillrectangle(340, 700, 640, 800);int x5 = 340 + (300 - textwidth(e)) / 2;int y5 = 700 + (100 - textheight(e)) / 2;outtextxy(x5, y5, e);FlushBatchDraw();MOUSEMSG msg;if (MouseHit()) {msg = GetMouseMsg();if (msg.uMsg == WM_LBUTTONDOWN) {if (msg.x >= 120 && msg.x <= 520 && msg.y >= 150 && msg.y <= 250) {};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 300 && msg.y <= 400) {putdata();};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 450 && msg.y <= 550) {deldata();};if (msg.x >= 120 && msg.x <= 520 && msg.y >= 600 && msg.y <= 700) {char p[50];char v[50];InputBox(p, 50, "请输入修改的密码");InputBox(v, 50, "请在次输入密码");if (strcmp(p, v) == 0) {strcpy_s(p, password);HWND hwnd = GetHWnd();SetWindowText(hwnd, "提示");int i = MessageBox(hwnd, "修改成功", "提示", MB_OK);}else {HWND hwnd = GetHWnd();SetWindowText(hwnd, "提示");int i = MessageBox(hwnd, "两次输入的密码不一样", "提示", MB_OK);}};if (msg.x >= 340 && msg.x <= 640 && msg.y >= 700 && msg.y <= 800) {HWND hwnd = GetHWnd();SetWindowText(hwnd, "退出");int i = MessageBox(hwnd, "是否返回到主菜单", "提示", MB_OKCANCEL);if (i == 1) {return;}};}}}
}

全部的功能还未完全的实现

我对删除以及,录入有了新的想法

也许我们不用一开始就在文件上面操作

我们可以设置一个函数,在程序结束的时候,来执行这个函数,也许他们习惯用左上的x来关闭窗口但是我也许可以设置特殊的界面x键不可以点

这是管理员的界面 

 有了菜单还是有了更多的方向了,接下来的时间我会把图中的功能一一的实现

今天撒花谢幕了 拜拜!!!!