本文介绍了菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

优秀的程序员

我正在开发一个简单的Web浏览器,我想在Form1的SystemMenu中添加一个带有文本"Save"的项目。加上键盘组合"Ctrl + s",为用户提供更多功能,如下图所示:

Good programmers
I am developing a simple web browser, and I would like to add to Form1's SystemMenu an Item with text "Save" plus keyboard combination "Ctrl + s", to offer the user more functionality, as in the following figure:

在互联网上查找示例,但它只允许我添加一个带有文本"Save"的项目。

Look for an example on the internet, but it only allows me to add an Item with text "Save".

<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
    Private Shared Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
    End Function

    <DllImport("user32.dll")>
    Private Shared Function InsertMenu(ByVal hMenu As IntPtr, ByVal wPosition As Int32, ByVal wFlags As Int32, ByVal wIDNewItem As Int32, ByVal lpNewItem As String) As Boolean
    End Function

    Private Const MF_BYPOSITION As Integer = &H400
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim sysMenu As IntPtr = GetSystemMenu(Me.Handle, False)
        InsertMenu(sysMenu, 2, MF_BYPOSITION, 0, "Save")

    End Sub




问题是:

我无法添加键盘组合"Ctrl + s"到项目。

 有谁可以帮助我吗。


The big problem is:
I can not add the keyboard combination "Ctrl + s" to the item.
  Can someone help me please.

推荐答案

&NBSP;&NBSP;
InsertMenu(sysMenu,2,MF_BYPOSITION,0,
" Save"
& Chr(9)&
" Ctrl + S"

  InsertMenu(sysMenu, 2, MF_BYPOSITION, 0, "Save" & Chr(9) & "Ctrl+S")

然后你必须实现该功能。


这篇关于菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 13:11