Hej NG
Jeg fandt engang for længe siden følgene eks. ude på 'nettet':
Option Explicit
Public Const MF_BITMAP = &H4&
Public Const MIIM_ID = &H2
Public Const MIIM_TYPE = &H10
Public Const MFT_STRING = &H0&
Public Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubmenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA"
(ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo
As MENUITEMINFO) As Boolean
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As
Long) As Long
Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos
As Long) As Long
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 Sub Form_Load()
On Error GoTo err
Dim hMenu As Long, hSubmenu As Long
Dim hID As Long
Me.Hide
'Get the menuhandle of your app
hMenu = GetMenu(Me.hwnd)
'Get the handle of the first submenu (Hello)
hSubmenu = GetSubMenu(hMenu, 0)
'Get the menuId of the first entry (Bitmap)
hID = GetMenuItemID(hSubmenu, 0)
'Add the bitmap
'You can add two bitmaps to a menuentry
'One for the checked and one for the unchecked
'state.
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, Me.Picture1.Picture,
Me.Picture2.Picture
End Sub
Dette placerer et bitmap oppe på menuen. - Når jeg kører dette i eksemplet
kører det fint, variablerne
hMenu, hSubmenu og hID fpr alle værdier > 0.
I min applikation som bla. består af MDIForm og så en MDIChild form. Menu er
lavet på Childformen. Jeg har forsøgt at bruge hMenu =
GetMenu(MDIChild.hwnd) og også hMenu = GetMenu(MDIForm.hwnd) i begge
tilfælde for hMenu > 0 MEN i begge tilfælde bliver hSubmenu =
GetSubMenu(hMenu, 0) = 0 - hvilket så resulterer i at hID = -1, og jeg får
ikke sat bitmap billedet.
Jeg er sikker på at problemet ligger i at jeg benytter kombinationen
MDIChild / MDIForm
Er der noget der har en løsning.
/Johnny
|