• C++ AppendMenu


    主题

    1.  系统菜单下面添加自定义菜单

    2.  

    3.  

    4.  

    5.  

      
        

    AppendMenu

    The AppendMenu function appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item.
     
    Note  The AppendMenu function has been superseded by the InsertMenuItem function. You can still use AppendMenu, however, if you do not need any of the extended features of InsertMenuItem.
        
    BOOL AppendMenu(
      HMENU hMenu,         // handle to menu
      UINT uFlags,         // menu-item options
      UINT_PTR uIDNewItem, // identifier, menu, or submenu
      LPCTSTR lpNewItem    // menu-item content
    );

    ID

    Value

    Description

    1. 

    MF_BITMAP

    位图

    2. 

    MF_DISABLED

    不可用

    3. 

    MF_ENABLED

    可用

    4. 

    MF_GRAYED

    灰色

    5. 

    MF_MENUBARBREAK

    6. 

    MF_MENUBREAK

    7. 

    MF_OWNERDRAW

    8. 

    MF_POPUP

    9. 

    MF_SEPARATOR

    分隔符号

    10. 

    MF_STRING

    字符串

    11. 

    MF_CHECKED

    勾上

    12. 

    MF_UNCHECKED

    取消勾上

          

    代码::系统菜单下面添加自定义菜单

    1.在Resource.h里面 定义1个ID号

    #define ID_MENU1 0x1500
     
    2.在::OnInitDialog() 下面添加代码
    // TODO: Add extra initialization here
    CMenu*    pMenu = GetSystemMenu(FALSE);                    
    CString menu1="新菜单";                                
    pMenu->AppendMenu(MF_SEPARATOR);                        
    pMenu->AppendMenu(MF_STRINGID_MENU1menu1);
        
    3.在::OnSysCommand(UINT nIDLPARAM lParam) 下面添加响应单击 这个菜单的代码
    void CProject02Dlg::OnSysCommand(UINT nIDLPARAM lParam)
    {
        if ((nID & 0xFFF0) == IDM_ABOUTBOX)
        {
            CAboutDlg dlgAbout;
            dlgAbout.DoModal();
        }
        else if (nID==ID_MENU1)
        {
            MessageBox("YES");
        }
        else
        {
            CDialog::OnSysCommand(nID, lParam);
        }
    }
     
        

    效果图:

      

        
    //OnSysCommand

    ID

    nID

    备注:OnSysCommand

    1.

    SC_CLOSE

    Close the CWnd object.

    2.

    SC_MAXIMIZE

    (or SC_ZOOM) Maximize the CWnd object.

    3.

    SC_MINIMIZE

    (or SC_ICON) Minimize the CWnd object.

    4.

    SC_MOVE

    Move the CWnd object

    5.

    SC_RESTORE

    Restore window to normal position and size.

    6.

    SC_SIZE

    Size the CWnd object.

    7.

    SC_NEXTWINDOW

    Move to the next window.

    8.

    SC_PREVWINDOW

    Move to the previous window.

    9.

    SC_KEYMENU

    Retrieve a menu through a keystroke.

    10.

    SC_MOUSEMENU

    Retrieve a menu through a mouse click.

    11.

    SC_HOTKEY

    Activate the CWnd object associated with the application-specified hot key.

    12.

    The low-order word of lParam identifies the HWND of the window to

    13.

    SC_SCREENSAVE

    Executes the screen-saver application specified in the [boot] section of the SYSTEM.INI file.

    14.

    SC_TASKLIST

    Execute or activate the Windows Task Manager application.

    15.

    SC_VSCROLL

    Scroll vertically.

    16.

    SC_HSCROLL

    Scroll horizontally.





  • 相关阅读:
    我的第一个B2C 网上图书商店,初始化
    JFreeChat学习圆饼状图的创建(结合serlvet,非原创)!
    JFreeChat学习柱状图的创建(X,Y轴的口口问题还未解决,固暂时使用拼音表示)
    JFreeChat学习柱状图关于 口口 的进一步解决方案
    JSON发送的工具类分享,应该还是蛮常用的!
    linux 常见命令
    mysql常用命令
    php 实现树状无限分类查询
    轻量级的mvc框架封装
    lamp 环境下,php7.0以上,配置重写rewrite,影藏index.php
  • 原文地址:https://www.cnblogs.com/xe2011/p/3885691.html
Copyright © 2020-2023  润新知