在用户窗体上添加菜单.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
在用户窗体上添加菜单

在用户窗体上添加菜单 在VBA中,用户窗体上是没有菜单的,为了使用方便,我们可以使用API函数在用户窗体上添加菜单,示例代码如下: #001 Private Declare Function FindWindow Lib user32 Alias FindWindowA (ByVal lpClassName As String, ByVal lpWindowName As String) As Long #002 Private Declare Function SetMenu Lib user32 (ByVal hwnd As Long, ByVal hMenu As Long) As Long #003 Private Declare Function CreateMenu Lib user32 () As Long #004 Private Declare Function AppendMenu Lib user32 Alias AppendMenuA (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long #005 Private Declare Function DestroyMenu Lib user32 (ByVal hMenu As Long) As Long #006 Private Declare Function CreatePopupMenu Lib user32 () As Long #007 Private Declare Function SetWindowLong Lib user32 Alias SetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long #008 Private Declare Function GetWindowLong Lib user32 Alias GetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long) As Long #009 Private Const GWL_WNDPROC = (-4) #010 Private Const MF_STRING = H0 #011 Private Const MF_POPUP = H10 #012 Private Const MF_SEPARATOR = H800 #013 Dim MenuWnd As Long, Dump As Long, PopupMenuID As Long, PopupMenuWnd As Long, MenuID As Long #014 Private Sub UserForm_Initialize() #015 If Val(Application.Version) 9 Then #016 hwnd = FindWindow(ThunderXFrame, Me.Caption) #017 Else #018 hwnd = FindWindow(ThunderDFrame, Me.Caption) #019 End If #020 MenuWnd = CreateMenu() #021 PopupMenuID = CreatePopupMenu() #022 Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, 系统设置(X)) #023 Dump = AppendMenu(PopupMenuID, MF_STRING, 100, 保存(S)...) #024 Dump = AppendMenu(PopupMenuID, MF_STRING, 101, 备份(E)) #025 Dump = AppendMenu(PopupMenuID, MF_STRING, 102, 退出(X)) #026 PopupMenuID = CreatePopupMenu() #027 Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, 会计凭证(P)) #028 Dump = AppendMenu(PopupMenuID, MF_STRING, 110, 录入(L)) #0

文档评论(0)

haihang2017 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档