|
-
Jun 16th, 2011, 07:33 AM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - about menu items
i have code for put images in menus. but when i move the mouse, on it, the image is inverted(colored inverted). for these i only can see 1 or 2 solutions:
1 - change the highlight(mouse move select item) z order(i read something);
2 - change(if is possible) the highlight position\size.
how can i do it?
(the information, in internet, is "small" for these... i can't find it )
can anyone give me clues?
-
Jun 16th, 2011, 10:53 AM
#2
Re: [VB6] - about menu items
1 bit per pixel (black & white) mouse cursors can invert whatever they are over. Is that what you are seeing? If so, when you move the cursor over the menu text, that too should be color inverted
What would ZOrder have to do with anything? Are these real menu items or some custom control? More info.
-
Jun 16th, 2011, 04:22 PM
#3
Thread Starter
PowerPoster
Re: [VB6] - about menu items
 Originally Posted by LaVolpe
1 bit per pixel (black & white) mouse cursors can invert whatever they are over. Is that what you are seeing? If so, when you move the cursor over the menu text, that too should be color inverted
What would ZOrder have to do with anything? Are these real menu items or some custom control? More info.
the problem is the entire image not some pixels(every pixels).
the zorder is something that i read from here:
"'If the highlighted menu is the top of a poup menu, pass menu item by position" : http://www.developerfusion.com/code/...atus-messages/
-
Jun 21st, 2011, 08:21 AM
#4
Re: [VB6] - about menu items
What you are describing doesn't sound like normal behavior.
1. Are these menus a custom control?
2. If they are real menus, how are you assigning the images to the menus?
-
Jun 21st, 2011, 08:28 AM
#5
Thread Starter
PowerPoster
Re: [VB6] - about menu items
 Originally Posted by LaVolpe
What you are describing doesn't sound like normal behavior.
1. Are these menus a custom control?
2. If they are real menus, how are you assigning the images to the menus?
are real menus.
Code:
Option Explicit
Private 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
Const MF_BYPOSITION = &H400&
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
Private Declare Function GetMenuItemInfo Lib "user32.dll" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private Declare Function SetMenuItemInfo Lib "user32.dll" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private Const MIIM_STATE = &H1
Private Const MIIM_ID = &H2
Private Const MIIM_SUBMENU = &H4
Private Const MIIM_CHECKMARKS = &H8
Private Const MIIM_DATA = &H20
Private Const MIIM_TYPE = &H10
Private Const MFT_BITMAP = &H4
Private Const MFT_MENUBARBREAK = &H20
Private Const MFT_MENUBREAK = &H40
Private Const MFT_OWNERDRAW = &H100
Private Const MFT_RADIOCHECK = &H200
Private Const MFT_RIGHTJUSTIFY = &H4000
Private Const MFT_RIGHTORDER = &H2000
Private Const MFT_SEPARATOR = &H800
Private Const MFT_STRING = &H0
Private Const MFS_CHECKED = &H8
Private Const MFS_DEFAULT = &H1000
Private Const MFS_DISABLED = &H2
Private Const MFS_ENABLED = &H0
Private Const MFS_GRAYED = &H1
Private Const MFS_HILITE = &H80
Private Const MFS_UNCHECKED = &H0
Private Const MFS_UNHILITE = &H0
Private Sub Form_Load()
Dim i As MENUITEMINFO
Dim hMenu As Long, hSubMenu As Long
'get the handle of the menu
hMenu = GetMenu(Me.hwnd)
'get the first submenu
hSubMenu = GetSubMenu(hMenu, 0)
'set the menu bitmap
SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture
i.cbSize = Len(i)
i.fMask = MIIM_SUBMENU
Debug.Print GetMenuItemInfo(hSubMenu, 0, True, i)
With i
.fMask = MIIM_TYPE
' This is a regular text item.
.fType = MFT_BITMAP Or MFT_STRING
' The text to place in the menu item.
'i.dwTypeData =
End With
Debug.Print SetMenuItemInfo(hSubMenu, 0, True, i)
End Sub
Private Sub mnuFileExit_Click()
End
End Sub
i'm trying use the menuiteminfo functions for try avoid that ineverted images, but without sucess
-
Jun 21st, 2011, 09:40 AM
#6
Re: [VB6] - about menu items
I've never used that API for setting bitmaps. Always have used subclassing & custom drawing, but is far more difficult.
Per MSDN documentation for that API: "The selected and clear bitmaps should be monochrome. The system uses the Boolean AND operator to combine bitmaps with the menu so that the white part becomes transparent and the black part becomes the menu-item color. If you use color bitmaps, the results may be undesirable."
This means, per the documentation, that the images should be 2 colors: white = transparent, and any other color for the image.
Reading the above, it explains your problem. Basically, windows is masking colors in your image, similar to how sprites work. Here is another thread related to your problem, but was not resolved.
-
Jun 21st, 2011, 09:47 AM
#7
Thread Starter
PowerPoster
Re: [VB6] - about menu items
 Originally Posted by LaVolpe
I've never used that API for setting bitmaps. Always have used subclassing & custom drawing, but is far more difficult.
Per MSDN documentation for that API: "The selected and clear bitmaps should be monochrome. The system uses the Boolean AND operator to combine bitmaps with the menu so that the white part becomes transparent and the black part becomes the menu-item color. If you use color bitmaps, the results may be undesirable."
This means, per the documentation, that the images should be 2 colors: white = transparent, and any other color for the image.
Reading the above, it explains your problem. Basically, windows is masking colors in your image, similar to how sprites work. Here is another thread related to your problem, but was not resolved.
then every colors icons, in menus, that we have seen, are OWNERDRAWRED or a new control.. but is possible change the VB6 menu control to system menu?(for avoid these bugs.. i know that the OS have anothers menus controls)
-
Jun 21st, 2011, 09:58 AM
#8
Re: [VB6] - about menu items
You might want to search the codebank and utitlies sections of the forum for menu controls or custom menus. There are projects on the web (i.e., vbAccelerator, PlanteSourceCode) that use menu images. There are also controls (freeware/commercial) that enable custom menus.
-
Jun 22nd, 2011, 05:23 AM
#9
Thread Starter
PowerPoster
Re: [VB6] - about menu items
who said that we(beginners) can't create our own menus styles!?!
i found these nice tutorial and the code seems easy to change\adapt to our menus
http://www.vboffbeat.com/omt01.html
(i share these tutorial with everyone)
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|