1.程序入口地址,即主函数WinMain:
int APIENTRY WinMain(HINSTANCE hInstance, //本模块实例句柄 HINSTANCE hPreInstance, //前一个实例句柄,现已不用 LPSTR lpCmdLine, //命令行参数 int nCmdShow) //主窗口初始化时的显示方式 { ... return 0; }
- hInstance指定当前模块的实例句柄,可用GetModuleHandle()函数获得:
hInstance = (HINSTANCE)GetModuleHandle(NULL);
- lpCmdLine是命令行参数。其值由CreateProcess()函数的第二个参数决定。应用程序初始化时检查这个参数决定是否打开特定文档。
- nCmdShow指定窗口显示方式,也是由CreateProcess()函数传递的。
2.弹出对话框MessageBox:
int MessageBox(HWND hWnd, //窗口句柄,指定哪个窗口拥有创建的消息框 LPCTSTR lpText, //消息内容 LPCTSTR lpCaption, //标题 UNIT uType //指定对话框的内容和行为 );
- HWND唯一标识一个特定的窗口。
- uType的值可以是下列各组标志的一个标志组合,用 ”|“ 连接:
- 为显示按钮,指定下组中的一个值:
- MB_OK :确定
- MB_OKCANCEL :确定和取消
- MB_ABORTRETRYIGNORE :终止、重试和忽略
- MB_YESNOCANCEL :是、否和取消
- MB_YESNO :是和否
- MB_RETRYCANCEL :重试和取消
- 显示图标:
- MB_ICONHAND :停止图标
- MB_ICONQUESTION :询问图标
- MB_ICONEXCLAMATION :感叹图标
- 为显示按钮,指定下组中的一个值:
-
- 指示默认的选中按钮:
- MB_DEFBUTTON1 :第一个按钮是默认选中按钮
- MB_DEFBUTTON2
- MB_DEFBUTTON3
- MB_DEFBUTTON4
- 指示默认的选中按钮:
- MessageBox返回值可以是:IDOK,IDCANCEL,IDYES,IDNO,IDABORT,IDRETRY,IDIGNORE。