zoukankan      html  css  js  c++  java
  • windows程序设计 MessageBox消息框

    MessageBox函数

    int
    WINAPI
    MessageBoxW(
        HWND hWnd,//窗口句柄
        LPCWSTR lpText,//消息框主体显示的字符串
        LPCWSTR lpCaption,//消息框标题上的字符串
    UINT uType//样式
    );
    

      

    样式有
    #define MB_OK                       0x00000000L
    #define MB_OKCANCEL                 0x00000001L
    #define MB_ABORTRETRYIGNORE         0x00000002L
    #define MB_YESNOCANCEL              0x00000003L
    #define MB_YESNO                    0x00000004L
    #define MB_RETRYCANCEL              0x00000005L
    

      

    测试代码

    #include <windows.h>
    
    //hInstance:执行实体句柄,lpCmdLine:执行程序的命令列,nCmdShow:程序最初显示的方式。
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
    
    	//窗口句柄,消息框主体显示的字符串,消息框标题上的字符串,样式。
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_OK);
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_OKCANCEL);
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_ABORTRETRYIGNORE);
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_YESNOCANCEL);
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_YESNO);
    	MessageBox(NULL, TEXT("Hello, small insect !"), TEXT("message"), MB_RETRYCANCEL);
    
    	return 0;
    }
    

      

    运行之后的结果是

    除了这些样式,还有别的样式,可以选中MB_OK,按F12就能看到和消息框的样式了。

    MessageBox函数还可返回IDYES、IDNO、IDCANCEL、IDABORT、 IDRETRY或IDIGNORE。

  • 相关阅读:
    echarts数据包坐标拾取工具
    JS 多个条件判断
    js 实现各浏览器全屏
    前端统计使用插件
    JS 随机排序算法
    js中布尔值为false的六种情况
    Mosaic
    单点登录
    JavaScript数据结构和算法
    一个普通函数的冷僻属性(length、caller、arguments、name、[[Scopes]]和[[FunctionLocation]])
  • 原文地址:https://www.cnblogs.com/xuqiulin/p/9975511.html
Copyright © 2011-2022 走看看