Results 1 to 9 of 9

Thread: [RESOLVED] [VB6] - about menu items

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Resolved [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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Re: [VB6] - about menu items

    Quote Originally Posted by LaVolpe View Post
    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/
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Re: [VB6] - about menu items

    Quote Originally Posted by LaVolpe View Post
    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Re: [VB6] - about menu items

    Quote Originally Posted by LaVolpe View Post
    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)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width