相信每一位刚入门的程序员都在想什么时候我才能做一个软件或者像是软件的程序,今天小编来为大家献上程序创建界面的方法——EasyX图形库
- 首先下载EasyX图形库官方下载
同时在此官网中有关于安装的教程和部分教学视频,大家可以自行学习研究一下 - 安装完成后大家可以以这几个头文件进行调用
复制代码
1
2
3
4#include <easyx.h> #include <conio.h> #include <graphics.h>
- 关于具体使用方法大家可参见EasyX官方文档EasyX官方文档,文档提供在线阅读和下载阅读两种方式,具体的例子可见文档示例程序
点开cpp文件后会有一些示例程序如:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42// 编译环境:Visual C++ 6.0,EasyX 20180504(beta) // http://www.easyx.cn // #include <graphics.h> #include <time.h> #include <conio.h> int main() { // 设置随机函数种子 srand((unsigned) time(NULL)); // 初始化图形模式 initgraph(640, 480); int x, y; char c; settextstyle(16, 8, _T("Courier")); // 设置字体 // 设置颜色 settextcolor(GREEN); setlinecolor(BLACK); for (int i = 0; i <= 479; i++) { // 在随机位置显示三个随机字母 for (int j = 0; j < 3; j++) { x = (rand() % 80) * 8; y = (rand() % 20) * 24; c = (rand() % 26) + 65; outtextxy(x, y, c); } // 画线擦掉一个像素行 line(0, i, 639, i); Sleep(10); // 延时 if (i >= 479) i = -1; // 循环处理 if (_kbhit()) break; // 按任意键退出 } // 关闭图形模式 closegraph(); }
更多的操作需要各位小伙伴们自行观看官方文档
小编在这里提供几种使用方法
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#include <easyx.h> #include <conio.h> #include <graphics.h> #include <stdio.h> #include <iostream> #include <stdlib.h> #include <fstream> #include <string> using namespace std; IMAGE word1; int main() { initgraph(1000,600);//初始化 1000*600 的软件界面 loadimage(&word1, "E://background/castle.jpg", 1000, 600); putimage(0,0,&word1); settextcolor(YELLOW); settextstyle(50, 0,_T("华文琥珀")); outtextxy(125, 80,_T("欢迎使用传说二叉树电话查询系统")); setcolor(LIGHTBLUE);//显示信息字体颜色为浅蓝 settextstyle(20, 0,_T("微软雅黑")); outtextxy(600,420,_T("学校:大学")); outtextxy(600,440,_T("学院:信息工程学院")); outtextxy(600,460,_T("专业:计算机系")); outtextxy(600,480,_T("小组:二哈的工作室")); outtextxy(600,500,_T("成员:")); outtextxy(600,520,_T(" ☆荣誉出品☆")); _sleep(100000); cleardevice(); closegraph(); }
- 设置窗口大小:initgraph(1000,600);//初始化 1000*600 的软件界面,必须有即开启画布
- 插入图片:loadimage(&word1, “E://background/castle.jpg”, 1000, 600);将目标图片路径及名字取出,设置图片取出后的长和宽,这里小编设置了窗口的长和宽即1000*600
- 放置图片位置:putimage(0,0,&word1);以窗口左上角为(0,0)坐标放置在(0,0)处开始
- 添加文字:settextcolor(YELLOW);设置文字的颜色黄色;这里的YELLOW是库的内置定义settextstyle(50, 0,_T(“华文琥珀”));设置字体样式,50是字体的大小
放置文字outtextxy(125, 80,_T(“欢迎使用传说二叉树电话查询系统”));(125,80)是文字的起始坐标。 - _sleep(100000)由于程序一直向下执行小编在这里加了函数站厅100000ms,或者可以用getchar();
- 最后closegraph();关闭画布
最后小编祝各位day day up!更多操作请观看EasyX图形库官网
最后
以上就是沉静项链最近收集整理的关于VC6.0++基于EasyX图形库创建程序界面的全部内容,更多相关VC6内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复