 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
nitrix Guest
|
Posted: Wed Oct 24, 2007 5:36 pm Post subject: |
|
|
Fantastic !
i tried something similar, but i must have forgotten something
thanks you so much lexikos, you made my day  |
|
| Back to top |
|
 |
Alekoz
Joined: 17 Jun 2007 Posts: 153
|
Posted: Wed Oct 24, 2007 9:28 pm Post subject: |
|
|
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  _________________ My BF2 Scripts |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2474 Location: Australia, Qld
|
Posted: Wed Oct 24, 2007 10:14 pm Post subject: |
|
|
| 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  | 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 |
|
 |
Guest
|
Posted: Fri Oct 26, 2007 2:06 pm Post subject: |
|
|
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
|
Posted: Fri Dec 21, 2007 6:52 pm Post subject: |
|
|
| 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 |
|
 |
Nahusa Guest
|
Posted: Mon Dec 24, 2007 7:20 am Post subject: |
|
|
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
|
Posted: Mon Dec 24, 2007 11:22 am Post subject: |
|
|
| 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 |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3600 Location: Belgrade
|
Posted: Mon Dec 24, 2007 12:04 pm Post subject: |
|
|
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 |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2474 Location: Australia, Qld
|
Posted: Mon Dec 24, 2007 12:46 pm Post subject: |
|
|
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.
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 |
|
 |
Nahusa Guest
|
Posted: Mon Dec 24, 2007 6:12 pm Post subject: |
|
|
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
|
Posted: Tue Dec 25, 2007 12:45 am Post subject: |
|
|
You need to pass the owner of the menus. In this case, the Gui.
| Code: | Gui, +LastFound
MI_EnableOwnerDrawnMenus(WinExist()) |
|
|
| Back to top |
|
 |
Nahusa Guest
|
Posted: Tue Dec 25, 2007 1:05 am Post subject: |
|
|
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
|
Posted: Tue Dec 25, 2007 9:13 am Post subject: |
|
|
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 |
|
 |
cooler99 Guest
|
Posted: Fri Mar 21, 2008 6:56 am Post subject: |
|
|
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
|
Posted: Sun Apr 27, 2008 10:20 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|