easyx图形库 其他函数
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<mmsystem.h>//包含多媒体设备接口头文件,放到#include<graphics.h>下面
#pragma comment(lib,"winmm.lib")//加载静态库这是预编译指令,不是语句不加;
void change()//修改窗口标题
{
HWND hnd = GetHWnd();//获取窗口句柄
SetWindowText(hnd,"欢迎");//设置窗口标题 第一个参数传入窗口句柄第二个参数设置字符串
}
int main()
{
initgraph(640, 480, SHOWCONSOLE);//创建窗口
change();
getchar();
closegraph();
return 0;
}
运行结果
#include<stdio.h>
#include<graphics.h>
void change()//修改窗口标题
{
HWND hnd = GetHWnd();//获取窗口句柄 hnd定义的变量
SetWindowText(hnd,"欢迎");//设置窗口标题 第一个参数传入窗口句柄第二个参数设置字符串
//弹出窗口提示用户操作 第一个参数传入窗口句柄或NULL第四个参数窗口有几个按钮
//MessageBox(NULL,"恭喜,中奖100元","提示",MB_OKCANCEL);
//如果第一个参数是NULL那么在点击确定或取消之前可以拖动"欢迎"窗口
//如果第一个参数是句柄那么再点击确定或取消之前不能拖动"欢迎"窗口
int isok=MessageBox(hnd, "恭喜,中奖100元", "提示", MB_OKCANCEL);//MessageBox返回int
if (isok == IDOK)
{
printf("你点击了ok\n");
}
else if (IDCANCEL)
{
printf("你点击了取消\n");
}
}
int main()
{
initgraph(640, 480, SHOWCONSOLE);//创建窗口
change();
getchar();
closegraph();
return 0;
}