#include <Windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
int res = MessageBox(NULL, L"Hello World", L"This is Window", MB_YESNO | MB_ICONASTERISK);
if (res == IDYES)
{
MessageBox(NULL, L"YES", L"MessageBox", NULL);
}
else if (res == IDNO)
{
MessageBox(NULL, L"NO", L"MEssageBox", NULL);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
int res = MessageBox(NULL, L"Hello World", L"This is Window", MB_YESNO | MB_ICONASTERISK);
if (res == IDYES)
{
MessageBox(NULL, L"YES", L"MessageBox", NULL);
}
else if (res == IDNO)
{
MessageBox(NULL, L"NO", L"MEssageBox", NULL);
}
return 0;
}
/*
1.Windows.h 头文件
Windows.h
Windef.h //基本数据类型
Winnt.h //支持unicode的类型定义
WinBase.h//Kernel函数
WinUser.h//用户界面函数
WinGDI.h //图形界面函数
2.WinMain 入口函数
int WINAPI WinMain(
HINSTANCE hIntance, //当前实例句柄
HINSTANCE hPrevInstance, //前一个实例句柄
LPSTR lpCmdLine, //接收命令行字符串
int nCmdShow //如何显示窗口
);
3.WINAPI 关键字
#define WINAPI __stdcall
定义一个调用约定,包括如何生产机器码,
以在堆栈中旋转函数调用的参数,许多Windows函数都定义为WINAPI.
4.MessageBox 函数
int MessageBox(
HWND hWnd, //窗口句柄
LPCTSTR lpText, //显示文本
LPCTSTR lpCaption,//标题文本
UINT uType //显示类型 MB_OK | MB_OKCANCEL | MB_YENO | MB_ICONASTERISK ... 详见MSDN
);
//返回被按下的按钮值
*/