• Domingo 22 de Diciembre de 2024, 09:19

Autor Tema:  Re: Menu con iconos  (Leído 1596 veces)

Valek

  • Nuevo Miembro
  • *
  • Mensajes: 11
    • Ver Perfil
Re: Menu con iconos
« en: Viernes 8 de Marzo de 2002, 09:10 »
0
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...

DaniMoreno

  • Nuevo Miembro
  • *
  • Mensajes: 4
    • Ver Perfil
Menu con iconos
« Respuesta #1 en: Lunes 27 de Enero de 2003, 16:17 »
0
Supongamos que tienes un menu como este:
Edicion
--Copiar
--Pegar
--Fuentes
------Arial
Dim hSubmenuFuentes As Long, hSubMenuEdicion As Long, hMenu As Long, idArial As Long
'barra de menus o menu principal
hMenu = GetMenu(hwnd)
'submenu edicion
hSubMenuEdicion = GetSubMenu(hMenu, 0)
'submenu fuentes
hSubmenuFuentes = GetSubMenu(hSubMenuEdicion, 2)
'ID del item
idArial = GetMenuItemID(hSubmenuFuentes, 0)
'colocamos el dibujo
I = SetMenuItemBitmaps(hSubmenuFuentes, idArial, &H4, Il1.ListImages(3).Picture, Il1.ListImages(3).Picture)
End Sub
Espero que te sirva de ayuda, Bye.