Foros del Web » Programación para mayores de 30 ;) » Programación General »

VB - Agregar Iconos al Menu

Estas en el tema de VB - Agregar Iconos al Menu en el foro de Programación General en Foros del Web. Hay alguna manera de poner los iconos al lado de cada opcion en los menus de los formularios? Para que quede un menu un poco ...
  #1 (permalink)  
Antiguo 01/06/2004, 03:56
 
Fecha de Ingreso: mayo-2004
Mensajes: 86
Antigüedad: 20 años
Puntos: 0
Pregunta VB - Agregar Iconos al Menu

Hay alguna manera de poner los iconos al lado de cada opcion en los menus de los formularios? Para que quede un menu un poco mas ameno.

|Archivo|Opciones|
_____________
| Opcion1 |
| Opcion2 |
| Opcion3 |

algo asi (pero no tan cutre,jaja )
__________________
Alguien sabe como es?
  #2 (permalink)  
Antiguo 01/06/2004, 03:58
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Con esta API:

BOOL SetMenuItemBitmaps(
HMENU hMenu, // handle to menu
UINT uPosition, // menu item
UINT uFlags, // options
HBITMAP hBitmapUnchecked, // handle to unchecked bitmap
HBITMAP hBitmapChecked // handle to checked bitmap
);

http://msdn.microsoft.com/library/de...tembitmaps.asp
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #3 (permalink)  
Antiguo 01/06/2004, 04:42
 
Fecha de Ingreso: mayo-2004
Mensajes: 86
Antigüedad: 20 años
Puntos: 0
Gracias pero era mas facil ponerlo en Visual BASIC.

Ya he visto que tengo que añadir esta linea:

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

Aqui lo dejo para quien le haga falta alguna vez. Solo hay que hacer el menu en un Form, y añadir unas pictures que son las que usaremos:

Option Explicit
'Esta API crea el Shell del Acerca de con los datos del Ordenador y demas
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hwnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long

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 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
Const MF_BYPOSITION = &H400&

Private Sub SetMenuIcon()
On Error Resume Next
Dim hMenu As Long
Dim hSubMenu As Long
Dim Ret As Long

'Get main menu ID
hMenu = GetMenu(hwnd)

'MENU FILE - Get sub menu 0 (Archivo - Items)
hSubMenu = GetSubMenu(hMenu, 0)

'set bitmap to menu item, by ordinal
Ret = SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, iNew.Picture, iNew.Picture)
Ret = SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, iOpen.Picture, iOpen.Picture)
Ret = SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, iSave.Picture, iSave.Picture)
'Skip the separator (it's 3)
Ret = SetMenuItemBitmaps(hSubMenu, 4, MF_BYPOSITION, iSave.Picture, iSave.Picture)
'Skip the separator (it's 5)
Ret = SetMenuItemBitmaps(hSubMenu, 6, MF_BYPOSITION, iExit.Picture, iExit.Picture)

' MENU EDIT - Get sub menu 1 (Edicion - Items)
hSubMenu = GetSubMenu(hMenu, 1)
Ret = SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, iCut.Picture, iCut.Picture)
Ret = SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, iCopy.Picture, iCopy.Picture)
Ret = SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, iPaste.Picture, iPaste.Picture)

' MENU EDIT - Get sub menu 2 (Ayuda - Items)
hSubMenu = GetSubMenu(hMenu, 2)
Ret = SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, iHelp.Picture, iHelp.Picture)

End Sub

Private Sub Form_Load()

On Error Resume Next
Call SetMenuIcon

End Sub

Private Sub menuAbout_Click()

On Error Resume Next
Call ShellAbout(hwnd, App.Title, "Autor:.....", Icon.Handle)

End Sub
__________________
Alguien sabe como es?
  #4 (permalink)  
Antiguo 01/06/2004, 04:45
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Sera mas facil para vos, la API de Windows esta hecha para C.

Lo encontraste sabien el nombre de la funcion?
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #5 (permalink)  
Antiguo 01/06/2004, 07:43
 
Fecha de Ingreso: mayo-2004
Mensajes: 86
Antigüedad: 20 años
Puntos: 0
Me imaginaba que estaba en C, porque en VB no se usan los ; para cerrar las sentencias. Y simplemente por logica me imagine que seria practicamente la misma funcion en VB que en C.

Gracias de todas formas!!!
__________________
Alguien sabe como es?
  #6 (permalink)  
Antiguo 01/06/2004, 07:52
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
No es una funcion ni de C de VB es una funcion del Sistema Operativo.

__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:12.