4
« en: Viernes 8 de Marzo de 2002, 09:10 »
Saludos, chicos.
Se me ha presentado un problema con la elaboración de un menu al cual le he agregado iconos; el menu es, mas o menos, de la siguiente forma:
[Main]
////[:)Opcion1]
////[:(Opcion2]
////[Opcion3>>]==>[Opcion4]
He hecho estas declaraciones:
Option Explicit
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 ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As String) 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
Private Declare Function GetMenuCheckMarkDimensions Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
El codigo es el siguiente:
Private Sub MDIForm_Load()
Dim hMenu, hSubMenu, menuID, x
hMenu = GetMenu(hwnd)
hSubMenu = GetSubMenu(hMenu, 0) '1 for "Other" menu etcetera
menuID = GetMenuItemID(hSubMenu, 0)
x = SetMenuItemBitmaps(hMenu, menuID, &H4, Img.ListImages(1).Picture, Img.ListImages(1).Picture)
menuID = GetMenuItemID(hSubMenu, 1)
x = SetMenuItemBitmaps(hMenu, menuID, &H4, Img.ListImages(2).Picture, Img.ListImages(2).Picture)
NOTA: tengo un ImageList con tres imagenes, la numero 3 aún no la he podido utilizar.
...Con esto he conseguido asignar Bitmaps a la opcion1 y a la opcion2...Esta claro que la opcion3 por ser de nivel superior no lleva bitmaps...EL GRAN PROBLEMA ES: asignar un bitmap a la opcion4...
Gracias de antemano, chicos.
Espero que puedan ayudarme...