AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Menu Icons v2 (stdlib)
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
nitrix
Guest





PostPosted: Wed Oct 24, 2007 5:36 pm    Post subject: Reply with quote

Fantastic !

i tried something similar, but i must have forgotten something

thanks you so much lexikos, you made my day Wink
Back to top
Alekoz



Joined: 17 Jun 2007
Posts: 153

PostPosted: Wed Oct 24, 2007 9:28 pm    Post subject: Reply with quote

this is nice
works great on my scripts with Standard Tray menu
but does it work with NoStandard menus?...and if yes how...im not that advanced at ahk so i need a little help Very Happy
_________________
My BF2 Scripts
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2474
Location: Australia, Qld

PostPosted: Wed Oct 24, 2007 10:14 pm    Post subject: Reply with quote

Alekoz wrote:
this is nice
works great on my scripts with Standard Tray menu
but does it work with NoStandard menus?...and if yes how...im not that advanced at ahk so i need a little help Very Happy
Confused Question It works the same way... If you are referring to the test script (with icons in the tray menu) you may have to change the item numbers.
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Oct 26, 2007 2:06 pm    Post subject: Reply with quote

Very good, thanks, but a little slow for my PC ( P4 1,5Ghz) and a menu with 33 items with their icons.
1st run: 9sec, 2nd run: 4+ sec)
Back to top
majkinetor



Joined: 24 May 2006
Posts: 3600
Location: Belgrade

PostPosted: Fri Dec 21, 2007 6:52 pm    Post subject: Reply with quote

Quote:
MI_ExtractIcon(Filename, IconNumber, IconSize)
{
; LoadImage is not used..
; ..with exe/dll files because:
; it only works with modules loaded by the current process,
; it needs the resource ordinal (which is not the same as an icon index), and
; ..with ico files because:
; it can only load the first icon (of size %IconSize%) from an .ico file.


Txh for this. I had troubles to resize exe and dll icons to other dimesnions then 16 and 32.
_________________
Back to top
View user's profile Send private message MSN Messenger
Nahusa
Guest





PostPosted: Mon Dec 24, 2007 7:20 am    Post subject: Reply with quote

Is it possible to make this work with a standard menu bar on a window? For example:

Code:

Menu, FileMenu, Add, Open, MenuHandler
Menu, FileMenu, Add, Exit, MenuHandler
Menu, MenuBar , Add, File, :FileMenu
Gui, Menu, MenuBar

Gui, Show, w100 h50
Return

MenuHandler:
{
   
}
Return

GuiEscape:
GuiClose:
{
    ExitApp
}
Return


I'd like the Open and Exit entries to have custom icons. I'm not sure if it's possible because of the requirement to use MI_ShowMenu(). Any thoughts?
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2474
Location: Australia, Qld

PostPosted: Mon Dec 24, 2007 11:22 am    Post subject: Reply with quote

No. Icons are not supported on the menu bar, even on Vista, which does not require MI_ShowMenu(). You could try using a toolbar instead. There are a couple toolbar examples in this thread; look for "ToolbarWindow32".
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3600
Location: Belgrade

PostPosted: Mon Dec 24, 2007 12:04 pm    Post subject: Reply with quote

lexikos probably didn't understand you.

You can do it. If not directly then using some workarounds...

Workaround: You can create main menu which main items launch normal menu's with icons. You then just need to position them right.
_________________
Back to top
View user's profile Send private message MSN Messenger
Lexikos



Joined: 17 Oct 2006
Posts: 2474
Location: Australia, Qld

PostPosted: Mon Dec 24, 2007 12:46 pm    Post subject: Reply with quote

Sorry, Nahusa. I didn't pay attention to the code in your post, since someone recently (today!) posted a very similar question. (Submenus of the menu bar may have icons, but not the menu bar itself.)
majkinetor wrote:
Workaround: You can create main menu which main items launch normal menu's with icons.

Another workaround would be to avoid owner-drawing. The only draw-back is that standard menu item bitmaps don't support transparency (except on Vista.) "Transparency" can be faked, but it doesn't look right when the item is selected. (See the "FakeAlphaTest" screenshot in my first post.)

Since the draw-backs aren't so bad, perhaps I'll write a function for it when I get time.

Edit: I added a new function (unrelated to the above workaround):

MI_EnableOwnerDrawnMenus( [ hwnd ] )
    Sub-classes a window to owner-draw menu icons. This allows the menu to be shown by means other than MI_ShowMenu(). If hwnd is omitted, the function operates on the script's main window, allowing menus shown with Menu,..,Show (as well as the main window's own menus) to be owner-drawn.
    Note:
    • This function should be called only once for any given window.
    • 'hwnd' must belong to the current process. (This may not apply on Win9x.)
    • If used on the script's main window, it breaks the "Pause Script" menu item (in either menu.)
MI_SetMenuStyle() now accepts a menu name or handle. I had been using a menu name in the example script, even though it accepted only a handle. Rolling Eyes

The "fake transparency" method still has one major benefit: it works for menus external to the current process. Eventually I'll add a function for it...
Back to top
View user's profile Send private message
Nahusa
Guest





PostPosted: Mon Dec 24, 2007 6:12 pm    Post subject: Reply with quote

I appreciate the help but I'm still having trouble making it work. Should it be as simple as this?:

Code:

MI_EnableOwnerDrawnMenus() ; No hwnd specified, use script's hwnd.

Menu, FileMenu, Add, Open, MenuHandler
  MI_SetMenuItemIcon("FileMenu", 1, "shell32.dll", 4, 16)
Menu, FileMenu, Add, Exit, MenuHandler
  MI_SetMenuItemIcon("FileMenu", 2, "shell32.dll", 1, 16)

MI_SetMenuStyle("FileMenu", 0x4000000)

Menu, MenuBar , Add, File, :FileMenu
Gui, Menu, MenuBar

Gui, Show, w100 h50

Return

MenuHandler:
{
   
}
Return

GuiEscape:
GuiClose:
{
    ExitApp
}
Return
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2474
Location: Australia, Qld

PostPosted: Tue Dec 25, 2007 12:45 am    Post subject: Reply with quote

You need to pass the owner of the menus. In this case, the Gui.
Code:
Gui, +LastFound
MI_EnableOwnerDrawnMenus(WinExist())
Back to top
View user's profile Send private message
Nahusa
Guest





PostPosted: Tue Dec 25, 2007 1:05 am    Post subject: Reply with quote

Ah, I was confused by the comment in lexikos' function:

Code:

if (hwnd="") {  ; Use the script's main window if hwnd was omitted.


I thought this would pass the needed hwnd automatically but, after doing some debugging, I see that the hwnd's differ. Thanks for the clarification.
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2474
Location: Australia, Qld

PostPosted: Tue Dec 25, 2007 9:13 am    Post subject: Reply with quote

To further clarify, the main window is the window that you get when you double-click the tray icon, or use ListLines, ListVars, etc. All menus shown with Menu,..,Show are owned by the script's main window.

A menu bar and any menus it shows are owned by whichever window contains it.

Owner-draw messages are sent only to the owner of the menu.
Back to top
View user's profile Send private message
cooler99
Guest





PostPosted: Fri Mar 21, 2008 6:56 am    Post subject: Reply with quote

Beautiful and Great!!!

Is it possible to have tooltips for each menu item "On Mouse Over"?
Back to top
heresy



Joined: 11 Mar 2008
Posts: 228

PostPosted: Sun Apr 27, 2008 10:20 pm    Post subject: Reply with quote

This is totally awesome. very handy.
since it supports .icl file there's no pain anymore to pack icons into .exe or .dll
cause every (include free) icon tools supports to make icon library (.icl)
i've added it to Function list in the Wiki.
hope this function come official soon.
Many Thanks Lexikos.

ps. btw what ItemClick label in the example stands for ?
_________________
Easy WinAPI - Dive into Windows API World
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group