/*
就是简单的批处理命令实现关机功能。文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
固然也能够调用windowsAPI的ExitWindowsEx函数实现文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
功能:关机/注销/重启/定时关机/撤销关机文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
用easyX画了几个框框当按钮,贴了一张背景图象文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
完全代码如下:文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
*/文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
include<stdlib.h>文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
include&34;文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
define H 320文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
define X2文章源自微观生活(93wg.com)微观生活-https://93wg.com/3257.html
//using namespace std;
void bk;
void bt;
void mhit;
int circlemouse;
int main
{
bk;
bt;
mhit;
getchar;
closegraph;
return 0;
}
//背景
void bk
{
initgraph;
loadimage, MAKEINTRESOURCE,W,H);
}
//画几个按钮
void bt
{
setfillcolor);
/*
setfillstyle;
*/
//方框长150 宽30,居中 各个按钮间距25,绘画开始点y坐标35
//按钮第1行 关机
fillrectangle;
//按钮第2行 重启
fillrectangle;
//按钮第3行 定时关机
fillrectangle;
//按钮第4行 撤销关机
fillrectangle;
//按钮第5行 休眠
fillrectangle;
//“注销” 填充圆
fillcircle;
settextcolor);//字体色彩洋红
setbkmode;//文字背景透明
settextstyle);
outtextxy, 40,_T);
outtextxy);
outtextxy);
outtextxy);
outtextxy);
outtextxy);
}
//鼠标移入移出效果和鼠标事件处理
void mhit
{
char cmd[] = &34;;
char s[10] = { 0 };
MOUSEMSG msg;
setlinestyle;
while
{
//清空鼠标动静缓冲区
FlushMouseMsgBuffer;
msg = GetMouseMsg;
setcolor;
//关机
if
{
rectangle;
if
system;
}
//重启
else if
{
rectangle;
if
system; //重启处理函数
}
//定时关机
else if
{
rectangle;
if
{
InputBox-1, &34;);
strcat;
system;
}
}
//撤销关机
else if
{
rectangle;
if
system;
}
//休眠 ;
else if
{
rectangle;
if
system;
}
//注销
else if )
{
fillcircle;
settextcolor);
outtextxy);
if
system;
}
else
{
setcolor;
rectangle;
rectangle;
rectangle;
rectangle;
rectangle;
circle;
}
}
}
//实现某圆形区域内鼠标效果 mx/my分别是当点鼠标坐标 r为圆半径
int circlemouse
{
//setorigin;
int l;
l = * + *;
if return 1;
return 0;
//setorigin;
}
以上就是微观生活(93wg.com)关于“关机小程序(C语言基础)”的详细内容,希望对大家有所帮助!
评论