Results 1 to 16 of 16

Thread: Changing the background of a menu icon

  1. #1
    Guest

    Question

    Hello,

    I have a question about changing the background color of an image in a menu. I have been able to load the images into certain menu-items, but for some strange reason, the background does not seem to change. So when people use the application on a different color-scheme, the backgroundcolor of the image in the menu would be messed up pretty bad.
    I have tried using 16 color bitmaps with the background set to gray (192192192), but that doesn't help.
    I also tried to change the background property of the image at runtime, but that doesn't help either.

    It's weird, because toolbar images (orignally the same images, but 16x16 pixels instead of 13x13) do get the correct system color.
    Is this a bug or am I overseeing something??

    Imar


  2. #2
    Guest
    By the way, what is the recommended number of colors in a Toolbar image?? 16, 256 or millions?? I can't find any info on recommendations.....

  3. #3
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241
    try to set a transparent color, for example, make your image's background blue or any other color, then choose it as transparent color, you can use microsoft photo editor for that thing or any other program, then save the image in GIF format, then add it to the menu, then try it, i'v never done this before, but if i will do it, i will do it like this, give it a go and let me know

  4. #4
    Guest
    Unfortunately, that doesn't work either. I tried that before.
    The funny thing is, using a transparent gif, the image will show up transparant on the form, but not on the menu.

    Thanks anyway.

    Imar

    Getting desperate...... ;-)

  5. #5
    Junior Member
    Join Date
    Mar 2000
    Location
    Montreal, QC
    Posts
    24

    Lightbulb

    LMar,

    It's my experience that if you follow the technique described on VB-World using the SetMenuItemBitmaps API (http://www.vb-world.net/controls/tip64.html) and use 256 or 16-Color GIF with no transparencies, then the color white is automatically used as the transparent one. The only problem with this though, is that I haven't figured how to actually display the color white. Anyways, hope this helps.

    JMik

  6. #6
    Guest
    He JMik,

    Thanks for your reply. This helps a lot. This also seems to work with 16 or 256 colors BMP's. White is indeed used as the transparant color.
    I tried to use an almost white color (254-255-255) to display as white, but that doesn't seem to work. I'll let you know when I find out how to display white.

    Thanks again,

    imar

  7. #7
    Guest
    Hmmm, it's still not perfect. For some reason, my icons turn out darker than they are. For instance I use bright yellow (255-255-0) but that turns out as 212-208-0 in the menu. It looks like some filter has been applied to the image, but I can't find any settings for that.

    Anybody any suggestions?? It's almost driving me nuts

    Imar



  8. #8
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Lightbulb Use an image list

    Put all your images in an image list control and set the mask colour to the one you want as a background (remember to set the use mask colour flag to true).

    It might help to set your background colour to something horrendous like pure magenta.

    (You might have to exract the images as icons or something).

    I've done this, it works.



    Dan

  9. #9
    Guest
    Hi Judd,

    Thanks for your reaction. Unfortunately, this doesn't work as expected as well.
    I added an ImageList with the maskcolor set to true, and added an obscure backgroundcolor to all my images which I made the maskcolor.
    Then at runtime I copied the image from the ImageList to a PictureBox and then added that one to the menu. But at that moment the image seems to loose it's maskcolor.

    I haven't been able to add my pictures directly from the ImageLst to the menu's, as described in:
    http://www.vb-world.net/controls/tip64.html

    Is this possible?? Can I add images to the menu straight from the ImageList, instead of through a PictureBox?


    Imar

  10. #10
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Thumbs up

    Yes you can!

    Instead of (as in the tip):

    Code:
    SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP _
    Picture1.Picture, Picture1.Picture
    use

    Code:
    SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP _
    ImageList.ListImages(1).Picture, _
    ImageList.ListImages(1).Picture


    Dan


  11. #11
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Unhappy I see what you mean....

    Imar,

    My apologies...I've just been looking at your problem and I see what you mean.

    Mine appeared to work on some icons, but on others the background, indeed the whole bitmap appears to be 'dirty'

    That is, its undergone some colour corruption. Thinking about it I had a similar problem doing an Excel Addin, i couldn't get my custom bitmaps to be properly transparent in the right places. In the end I resorted to using built in buttonface icons which are transparent. I tried all ways I could think of to set the transparent colour with no luck.

    I think using white might work, I'm going to try it.



    Dan

  12. #12
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Thumbs up

    Imar,

    Me again! Yes, its seems that my suspicions are correct, regardless of which mask colour you set, it seems that pure white is used as the true transparent colour (it is properly transparent - no corruption, as was meantioned previously in this thread).

    I guess that means that if you want 'white' in your icons you'll have to use something almost but not quite white
    (e.g. RGB (255, 255, 254)

    As far as the 'dirtying' of the other colours - no idea unfortunately!



    Dan

  13. #13
    Junior Member
    Join Date
    Mar 2000
    Location
    Montreal, QC
    Posts
    24

    Angry

    Judd,

    Unfortunately, that would not work either. Pure white (255, 255, 255) or anything close to it (Say 250, 250, 250) is used as the transparency. Like Imar said earlier, it makes the icons look washed out.

    If anyone knows how to overcome this, please let us know!

    JMik

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Exclamation

    I'm not sure but i think those icons you're talking about are in 8bit colors.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15
    Guest
    It's me, hopping in the discussion again. A bit late but I was away for a while.

    Yes, what JMik is saying (and we all agree off, I guess) is that images appear washed out. There are a number of different situations for the images to show up in a menu. Sometimes it works, sometimes it doesn't. Here are my findings so far:

    1) I use standard 16 color BMP's in a PictureBox and use 192-192-192 as the gray background. This looks good on a default NT 4 color-scheme, but looks weird on a Windows 2000 or any different color scheme.

    2) I put images in an ImageList, use vbMagenta (255-0-255), or any other "default-color" as a background. I use the MaskColor of the ImageList, then either copy the images to a picturebox at runtime, or use the .Picture property of the ImageList directly to get the images in the menu. Both situations lead to an image in the menu with a vbMagenta or other "default-color" as the background: so none of these methods seem to work. It looks like VB is completely ignoring the MaskColor property when it concerns menu's.

    3) I use images with a white background. At runtime, the white is replaced by the current 3D Object color (ButtonFace in VB, I guess). This method comes closest to the end result, but unfortunately, a mask or a filter is applied to the image, making it indeed look a bit "dirty". Colors like bright yellow turn out a brownish yellow.
    Besides: it's not possible to have any white in your image. Any color close to white (i quote JMik: "Say 250, 250, 250") is changed to the ButtonFace color as well.

    For all three situations I used 16, 256, and 16.7 million color BMP's and I used GIF's as well.

    I've been looking around at some other forum's and newsgroups, but it seems very hard to answer this "simple" question:

    "How does one create menu-images whose background adapts to the current color-scheme: that is: ButtonFace in VB, or 3D Objects in Windows. I know it must be possible, because all of Microsoft's products support this feature.

    Anybody??

    Imar

    P.s. Thank you all for your help so far.

  16. #16
    Guest

    Cool Changing the background of a menu icon - One last Try

    One last try to bring this discussion to the attention of "Transparent Bitmap Wizards" ;-)

    I just can't imagine that this cannot be solved. I've seen dozens of apps with self-adapting menu-icons.

    Once more: Anyone??

    Any help will be greatly appreciated.

    Imar

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