博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ AppendMenu
阅读量:4320 次
发布时间:2019-06-06

本文共 2396 字,大约阅读时间需要 7 分钟。

主题

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_MENU1, menu1);
    
3.在 ::
OnSysCommand(
UINT 
nID
LPARAM 
lParam) 下面添加响应单击 这个菜单的代码
void 
CProject02Dlg::
OnSysCommand(
UINT 
nID
LPARAM 
lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
  
  else if (nID==ID_MENU1)
    {
        MessageBox("YES");
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}
 
    

效果图:

  011905598218771.png

    
//
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.

011906010402598.png

转载于:https://www.cnblogs.com/xe2011/p/3885691.html

你可能感兴趣的文章
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
团队编程项目作业2-团队编程项目开发环境搭建过程
查看>>
<Using parquet with impala>
查看>>
07-Java 中的IO操作
查看>>
通过镜像下载Android系统源码
查看>>
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
正则表达式的搜索和替换
查看>>
个人项目:WC
查看>>
地鼠的困境SSL1333 最大匹配
查看>>
flume+elasticsearch+kibana遇到的坑
查看>>
【MM系列】在SAP里查看数据的方法
查看>>
C#——winform
查看>>