扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
组件名称 | 属性 | 值 |
Form | Name | frmMain |
Caption | 菜单例子 | |
Frame | Name | fraStyle |
Caption | 菜单风格 | |
Label | Name | lblHelp |
Caption | 在窗体空白处单击鼠标右键 | |
OptionButton | Name | opnStyle |
Caption | Window 标准 | |
Index | 0 | |
OptionButton | Name | opnStyle |
Caption | XP 风格 | |
Index | 1 | |
OptionButton | Name | opnStyle |
Caption | 3D 立体风格 | |
Index | 2 | |
OptionButton | Name | opnStyle |
Caption | 渐变风格 | |
Index | 3 | |
OptionButton | Name | opnStyle |
Caption | 多彩风格 | |
Index | 4 |
Option Explicit Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long Private Type POINTAPI X As Long Y As Long End Type Dim menu As cMenu Private Sub Form_Load() ' 初始化菜单并添加菜单项 Set menu = New cMenu menu.CreateMenu menu.AddItem "open", LoadPicture("images\open.ico"), "打开", MIT_STRING menu.AddItem "save", LoadPicture("images\save.ico"), "保存", MIT_STRING menu.AddItem "print", LoadPicture("images\print.ico"), "打印", MIT_STRING menu.AddItem "find", LoadPicture("images\find.ico"), "查找", MIT_STRING menu.AddItem "sep1", LoadPicture(), "", MIT_SEPARATOR menu.AddItem "undo", LoadPicture("images\undo.ico"), "撤消", MIT_STRING menu.AddItem "redo", LoadPicture("images\redo.ico"), "重复", MIT_STRING menu.AddItem "sep2", LoadPicture(), "", MIT_SEPARATOR menu.AddItem "cut", LoadPicture("images\cut.ico"), "剪切", MIT_STRING menu.AddItem "copy", LoadPicture("images\copy.ico"), "复制", MIT_STRING menu.AddItem "paste", LoadPicture("images\paste.ico"), "粘贴", MIT_STRING menu.AddItem "sep3", LoadPicture(), "", MIT_SEPARATOR menu.AddItem "check", LoadPicture("images\check.ico"), "一个 CheckBox", MIT_CHECKBOX menu.AddItem "exit", LoadPicture("images\exit.ico"), "退出", MIT_STRING End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ' 单击鼠标右建弹出菜单 If Button = vbRightButton Then Dim pos As POINTAPI GetCursorPos pos menu.PopupMenu pos.X, pos.Y, POPUP_LEFTALIGN Or POPUP_TOPALIGN End If End Sub Private Sub Form_Unload(Cancel As Integer) ' 释放资源, 卸载窗体 Set menu = Nothing Dim frm As Form For Each frm In Forms Unload frm Next End Sub Private Sub opnStyle_Click(Index As Integer) ' 设置菜单风格 Select Case Index Case 0 ' Windows 标准 menu.Style = STYLE_WINDOWS Case 1 ' XP 风格 menu.Style = STYLE_XP Case 2 ' 3D 立体风格 menu.Style = STYLE_3D Case 3 ' 渐变风格 menu.Style = STYLE_SHADE Case 4 ' 多彩风格 menu.Style = STYLE_COLORFUL End Select End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者