(API 一切皆有可能)打造个性菜单栏
'新建一个窗体,name:frmMain capiton:菜单例子 代码如下'注:菜单可以添加图片信息,只需在 <menu.AddItem "open", LoadPicture(), "打开", MIT_STRING>
'中的添加路径 如LoadPicture(C:\Picture.ico)
Private Sub Form_Load()
' 初始化菜单并添加菜单项
Set menu = New cMenu
menu.CreateMenu
menu.AddItem "open", LoadPicture(), "打开", MIT_STRING
menu.AddItem "save", LoadPicture(), "保存", MIT_STRING
menu.AddItem "print", LoadPicture(), "打印", MIT_STRING
menu.AddItem "find", LoadPicture(), "查找", MIT_STRING
menu.AddItem "sep1", LoadPicture(), "", MIT_SEPARATOR
menu.AddItem "undo", LoadPicture(), "撤消", MIT_STRING
menu.AddItem "redo", LoadPicture(), "重复", MIT_STRING
menu.AddItem "sep2", LoadPicture(), "", MIT_SEPARATOR
menu.AddItem "cut", LoadPicture(), "剪切", MIT_STRING
menu.AddItem "copy", LoadPicture(), "复制", MIT_STRING
menu.AddItem "paste", LoadPicture(), "粘贴", MIT_STRING
menu.AddItem "sep3", LoadPicture(), "", MIT_SEPARATOR
menu.AddItem "check", LoadPicture(), "一个 CheckBox", MIT_CHECKBOX
menu.AddItem "exit", LoadPicture(), "退出", 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
......
......
具体请下载文件...
API 一切皆有可能.rar
(27.82 KB)