If you try to add images to a form menu using the common API calls to do that it works nicely. Now if I make another menu and I set it's visiblity to false so i use it only as a popup menu, the menu icons simply vanish!! they disapear. I think I understand what is going on. I think that whenever the menu is invisble and visble again it redraws itself, and thus erases the icons that were there (this is just my guess, i could be wrong about this)...
I searched for long time on this forum and found nothing. How do you do this? How do you add menu items to a popup menu without problems? I am able to add menu images to my form's menu just fine, I need to do the same for the popup.
I have tested that whenever you set the visbility of any menu item to false and back to true the menu image disapears.
See it works perfectly as a normal form menu when I sent the visibility to true. As soon as I set it to false and back to true then the images are gone!
Also, I tried keeping it always visbile, it works that way as expected as a popup menu! But that's not what I want, because the menu is not suppose to be part of my form (just a popup) and if i keep the visbility to true then it's part of my form
I appreciate any help. I am sure if you try this yourself you will find the same thing!
I'm not sure if this will work and I'm sure there is probably a better way of doing it, but could you place your menu on a second form, leave it visible and call it from your first form?
Well, I acctually had the same problem with the menu.
I just set the caption of the root menu to "" or space (I don't remember ) and enabled=false. This will disable the menu for the form but you can use it as popupmenu.
The bug is (or the problem is) when you set the visibility to false for any menu item and it has an image associated with it, the next time you set the visbility of that same menu item to true, the image is gone (i think because Windows redraws the menu tiem whenever it appears again!). So how do you keep the image there!
This problem occurs specially fi you are making popup menus where you set the visibility of the top level menu to false so it won't be part of your form menu and yet can be used as a popup menu.
the menu still popups, i am getting the menu, just without the images. That is the problem.
SO in conclusion, the Visible property for a menu item screwes things up if the menu has an image.
That's all I am trying to say. Hope to get some suggestions.
I have some code at home that I draw the images on the menus using APIs and subclassing. I will see if I do the same as you if
the issue occurs or not. If t works correctly I will post for you.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
did you look at Xdream's post (below) and tried what he said?
Originally posted by Xdream Hi Koya
Well, I acctually had the same problem with the menu.
I just set the caption of the root menu to "" or space (I don't remember ) and enabled=false. This will disable the menu for the form but you can use it as popupmenu.
good luck
regards,
xdream
Remember, if someone's post was not helpful, you can always rate their post negatively .
That is what I have always done, I don't see his point.... I tried it anyways, I think he didn't understand my point. In either way, i tried it, no success
this works for me. I'm using this code for the images:
Code:
'sub - set menu icons
Public Sub subSetMenuIcons()
On Error Resume Next
Dim I As Byte
Dim hMenu As Long
Dim hSubMenu As Long
Dim menuID As Long
With frmMain
'frmMain
hMenu = GetMenu(.hwnd)
'mnuMenu
hSubMenu = GetSubMenu(hMenu, 0)
'mnuMenuSettings
menuID = GetMenuItemID(hSubMenu, 0)
Call SetMenuItemBitmaps(hMenu, menuID, vbNull, .imgLst.ListImages(1).Picture, .imgLst.ListImages(1).Picture)
'mnuMenuHide
menuID = GetMenuItemID(hSubMenu, 2)
Call SetMenuItemBitmaps(hMenu, menuID, vbNull, .imgLst.ListImages(2).Picture, .imgLst.ListImages(2).Picture)
'mnuMenuExit
menuID = GetMenuItemID(hSubMenu, 4)
Call SetMenuItemBitmaps(hMenu, menuID, vbNull, .imgLst.ListImages(3).Picture, .imgLst.ListImages(3).Picture)
....
no it isn't working. I don't know why. If I remove the enabled=false from my form_load, it shows up fine with the images, if i put it back then it shows the popup menu without the images! this is really strange!
I dont know what the hell, the trick did it. I was initalizing something in the wrong order, i changed that last night because i was trying different things and i didn't set it back. now I noticed that and your trick actually worked! nice thank you I tried that before but I wasn't too sure it was going to work and it actually didn't, but since you told me that yours worked, I knew I could make it work somehow using the same idea, I kept at it until I got it
thank you again.
I wonder if there is another way out there, because I could still click on the "blank" menu but i can't see what's in it since it's disabled oh well. not very professionaly but works!
Well that's great if it is working now! I was really wondering why it didn't before.
I don't know how you could do it otherwise, maybe we find another (not cheated ) solution...
btw: how do you solve the problem with the pictures background? As far as I remember you need to insert a static bitmap and everybody who has another windows-color setting will still see the bitmap background (just as a square).
For everybody who likes to play around with menu pictures, here is an example.
hay,
sorry, I have no idea. I never tried inserting an image in the background. I will play with it maybe next week and will let you know if I come up with anything functional