Add icons in the menu

zhaozj2021-02-11  226

'API function declaration Option ExplicitPrivate Declare Function GetMenu Lib "user32" (Byval hwnd As Long) _ As Long' get a menu window handle, hwnd is the handle of the window Private Declare Function GetSubMenu Lib "user32" (Byval hMenu As _Long, Byval nPos As Long) As Long 'made submenu handle, nPos is the location of the menu Private Declare Function SetMenuItemBitmaps Lib "user32" (Byval _hMenu As Long, Byval nPos As Long, Byval wFlags As Long, Byval _hBitUnchecked As Long, Byval hBitChecked As Long) As long 'Sets the corresponding graphic const mf_bitmap = & h400 &' to put graphics (must be BMP format), 16 * 16, left and right, and hns formnu1, hSubMenu, HSubMenu1, HSubMenu, HSubMenu1, HsubMenu, HSubMenu1, HsubMenu As LonghMenu = GetMenu (me.hwnd) hSubMenu1 = GetSubMenu (hMenu, 0) 'to obtain a handle to the first submenu item menu SetMenuItemBitmaps hSubMenu1,0, MF_BITMAP, imagelist1.listimages (1) _.picture, imagelist1.listimages (1) .picture 'The first set of graphics for HSubMenu1, assumes that the imagelist control is loaded into graphical setmenuitembitmaps HsubMenu1, 1, mf_bitmap, imagelist1.listimages (2) _.picture, imagelist1.listimages (2) .PICTURE' Settings second, Also you can also set the XX item. HSUBMENU2 = GetSubmenu (HMENU, 1) 'The submenu handle of the second menu can also use setMenuitembitmaps to set its graphics, only change HSUBMENU1 to HSubMenu2' can be End Sub

转载请注明原文地址:https://www.9cbs.com/read-5882.html

New Post(0)