下载地址

VB 制作窗口带图标的菜单源代码实例

常用软件:压缩软件迅雷合集 》播放软件
资源大小:2.72K 更新时间:2019-10-03
资源类型:绿色安全 授权方式:免费下载
资源分类:VB源码 资源人气:555
适用平台:WinAll 推荐等级:
一键分享: 一键分享
() ()

内容简介

在这里小编给大家提供VB 制作窗口带图标的菜单源代码实例下载,都是比较常用和简单的。有需要学习相关编程的可以下载回去研究一下。
VB 6.0 制作一个带图标的窗口菜单,这种菜单大家都习以为常了,不过现在学习VB了,闲了做一个,跟着书中的源码来做的,把菜单栏每个菜单项的最左边添加一个图标,一来美化菜单,二来可起到很好的提示作用,其它代码就不帖了,下面只帖出关键性代码:
  Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
  Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, _
   ByVal nPos As Long) As Long
  Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, _
   ByVal nPos As Long) As Long
  Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, _
   ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, _
   ByVal hBitmapChecked As Long) As Long '声明API函数
  Const MF_bitmap = &H4& '菜单常数标志表,菜单条目是一幅位图
  Private Sub Form_Load()
   Dim i As Integer
   Dim M As Long
   Dim MD As Long
   M = GetMenu(Me.hwnd) '获取菜单句柄
   For i = 1 To 4 '为“文件”菜单下的子菜单添加图标
   MD = GetMenuItemID(GetSubMenu(M, 0), i - 1) '指定条目的菜单ID
   SetMenuItemBitmaps M, MD, MF_bitmap, ImageList1.ListImages(i).Picture, ImageList1.ListImages(i).Picture
   '在指定的菜单条目中添加图标
   Next
  End Sub
  Private Sub eixt_Click()
  End '退出
  End Sub

关键词:图标菜单