在用户窗体上添加菜单

在用户窗体上添加菜单

ID:42622666

大小:73.50 KB

页数:5页

时间:2019-09-19

在用户窗体上添加菜单_第1页
在用户窗体上添加菜单_第2页
在用户窗体上添加菜单_第3页
在用户窗体上添加菜单_第4页
在用户窗体上添加菜单_第5页
资源描述:

《在用户窗体上添加菜单》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、技巧1在用户窗体上添加菜单在VBA中,用户窗体上是没有菜单的,为了使用方便,我们可以使用API函数在用户窗体上添加菜单,示例代码如下:#001PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong#002PrivateDeclareFunctionSetMenuLib"user32"(ByValhwndAsLong,ByValhMenuAs

2、Long)AsLong#003PrivateDeclareFunctionCreateMenuLib"user32"()AsLong#004PrivateDeclareFunctionAppendMenuLib"user32"Alias"AppendMenuA"(ByValhMenuAsLong,ByValwFlagsAsLong,ByValwIDNewItemAsLong,ByVallpNewItemAsAny)AsLong#005PrivateDeclareFunctionDestroyMenuLib"user32"

3、(ByValhMenuAsLong)AsLong#006PrivateDeclareFunctionCreatePopupMenuLib"user32"()AsLong#007PrivateDeclareFunctionSetWindowLongLib"user32"Alias"SetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong,ByValdwNewLongAsLong)AsLong#008PrivateDeclareFunctionGetWindowLongLib"use

4、r32"Alias"GetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong)AsLong#009PrivateConstGWL_WNDPROC=(-4)#010PrivateConstMF_STRING=&H0 PrivateConstMF_POPUP=&H10 PrivateConstMF_SEPARATOR=&H800 DimMenuWndAsLong,DumpAsLong,PopupMenuIDAsLong,PopupMenuWndAsLong,M

5、enuIDAsLong#014PrivateSubUserForm_Initialize()#015IfVal(Application.Version)<9Then#016hwnd=FindWindow("ThunderXFrame",Me.Caption)#017Else#018hwnd=FindWindow("ThunderDFrame",Me.Caption)#019EndIf#020MenuWnd=CreateMenu()#021PopupMenuID=CreatePopupMenu()#022Dump=Appe

6、ndMenu(MenuWnd,MF_STRING+MF_POPUP,PopupMenuID,"系统设置(&X)")#023Dump=AppendMenu(PopupMenuID,MF_STRING,100,"保存(&S)...")#024Dump=AppendMenu(PopupMenuID,MF_STRING,101,"备份(&E)")#025Dump=AppendMenu(PopupMenuID,MF_STRING,102,"退出(&X)")#026PopupMenuID=CreatePopupMenu()#027D

7、ump=AppendMenu(MenuWnd,MF_STRING+MF_POPUP,PopupMenuID,"会计凭证(&P)")#028Dump=AppendMenu(PopupMenuID,MF_STRING,110,"录入(&L)")#029Dump=AppendMenu(PopupMenuID,MF_STRING,111,"审核(&C)")#030PopupMenuID=CreatePopupMenu()#031Dump=AppendMenu(MenuWnd,MF_STRING+MF_POPUP,PopupMen

8、uID,"会计账簿(&Z)")#032Dump=AppendMenu(PopupMenuID,MF_STRING,112,"记账(&T)")#033Dump=AppendMenu(PopupMenuID,MF_STRING,113,"结账(&J)")#034PopupMenuID=CreatePopupMenu()#

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。