Closed hoppfrosch closed 12 years ago
You access menu items by their index, not by their name. However, there was a bug in the SetIcon() function. I uploaded a fix and it should work now.
mnu[1].SetIcon("test.ico") mnu[1].Icon := "test.ico"
It's a pity that it only works with indices. I think its much more intuitive (in an object oriented sense) to use
Menu.Main.File.SetIcon("test.ico") instead of Menu[1][1].SetIcon("test.ico") esp. when you try to add some new menuitems and have to adapt all indices ....
BTW: It works with indices as expected/designed
One more question:
From your CGui_Examples\MenuExample.ahk:
Menu1 := new CMenu("Main")
;Adding a menu item
Menu1.AddMenuItem("hello", "test")
;Accessing a menu item and setting some of its properties
Menu1[1].Text := "Test"
Menu1[1].Checked := true
Menu1[1].Enabled := false
;Adding a submenu
Menu1.AddSubMenu("sub1", "Test")
Menu1[2].AddMenuItem("blup", "blup")
Menu1[2][1].SetIcon(A_AHKPath) ; Setting MenuIcon for "blup" - works as expected
Menu1[2].SetIcon(A_AHKPath) ; ???? Setting MenuIcon for "sub1" - Should this work ????
sub2 := New CMenu("sub2")
sub2.AddMenuItem("blah", "blah")
;Adding an existing menu as submenu
Menu1.AddSubMenu("sub2", sub2)
;Setting a menu's icon
sub2.Icon := A_AHKPath ; Setting menu icon for "sub2"
sub2[1].Icon := A_AHKPath ; Setting menu icon for "blah"
...
See the line with '????' - Is this expected to work? (I would expect ...) - What's the correct way to set menu icon for "sub1"?
True, but what about menu items with spaces or localization? If you think it's needed feel free to submit a patch ;)
As you stated here in AHK-Forum setting of icons of menuItems does not work as expected and is obviously an error: