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
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
lexikos*
Guest





PostPosted: Thu Mar 18, 2010 2:22 am    Post subject: Re: png files as menu icons? Reply with quote

segalion wrote:
Is possible to use ImageList from Listiview to use as icons in menus?
Not with this library (on its own).
Quote:
Ico files are really the worst bitmap solution...
Icons are not bitmaps. ICO files hold multiple sizes and formats, BMP and PNG do not. An ICO file is more closely equivalent to a GDI Icon object, which is what this library uses in most cases.
Back to top
segalion
Guest





PostPosted: Thu Mar 18, 2010 8:45 am    Post subject: thanks Reply with quote

Thanks Lexikos...

I was hardly using the gnome standart png icons in my programs ( http://art.gnome.org/themes/icon ), and is a problem for me duplicate all cliparts from .png to .ico. (as the names of icons are the same, I can make thing like to select diferent themes...)

I have tried png2ico.exe ( http://www.winterdrache.de/freeware/png2ico/ ) to convert some .pngs in one .ico file but this function dont works with more than the first icon inside .ico file.

Do you know if there are an alternative to use .png as menu icons?, or do you know how to use this library with a .ico file containing all icons I want to use?

Thanks in advance....
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Thu Mar 18, 2010 12:32 pm    Post subject: Reply with quote

AutoHotkey_L supports menu icons natively; it can use any supported image file as an icon.

ICO files are designed to contain multiple images, of varying sizes and colour depths - typically representing the same icon. When an icon is loaded from the file (using specific Win32 API's), the image closest to the requested size and the current display depth is used, not necessarily the first image. This is useful because icons usually don't scale well.

Though it is possible for an ICO file to hold multiple icons of the same format, the Win32 API does not directly support it. Additional code would be needed to manually extract the appropriate image from the ICO file. Even then, if each icon within the file additionally has multiple formats, there wouldn't be any clear way to determine which images belong to which "icon".

If you really want to package multiple icons in one file, you could create a resource-only DLL file or embed the icons in a compiled script (Compile_AHK II makes this easy). However, you'd probably need to convert each PNG file to an ICO file first.
Quote:
is a problem for me duplicate all cliparts from .png to .ico.
Why? Have you considered using a simple file loop to run png2ico once for each png?
Back to top
View user's profile Send private message Visit poster's website
segalion
Guest





PostPosted: Mon Mar 22, 2010 12:33 pm    Post subject: Thanks Lexikos Reply with quote

Im going to use your recomendation with file loop to run png2ico option...

I have seen your ahk mod !!! Shocked and maybe I would try that code later...

"Meus respeitos"
Back to top
segalion
Guest





PostPosted: Tue Mar 23, 2010 6:00 pm    Post subject: Hello Lexikos Reply with quote

Hello again Lexikos.

Im using your lib, and I am in troubles with launch of the menulabels. With menu icons sometimes dont respond to the selection of the menus. Sometimes I have to select, move the mouse to focus another and then select second time, and usually launch the label.

If I use standart menus (without icons, the response is as usual).

Do you know why can be this...

Thanks in advance.
Back to top
segalion
Guest





PostPosted: Tue Mar 23, 2010 6:13 pm    Post subject: Reply with quote

I have discover why it fails...
Its because Im using tooltips with active links, and calling ToolTip("",lParam,"") at WM_Notify().

If I disable this (not calling ToolTip("",lParam,"") in my WM_Notify() the menus work fine (but donk work the links).


Sorry by the bad report.
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Mar 24, 2010 8:23 am    Post subject: Reply with quote

I wasn't able to reproduce your problem, since the tooltip failed to show if I showed a menu...

Try adding the following immediately below the TTN_LINKCLICK: label in ToolTip():
Code:
      if NumGet(text+0) != TT_HWND
          return    ; NOT a tooltip notification.
Also, did you try leaving OnMessage() but commenting out the ToolTip() call? Which operating system are you on?
Back to top
View user's profile Send private message Visit poster's website
segalion
Guest





PostPosted: Wed Mar 24, 2010 10:08 am    Post subject: Thanks Lexikos Reply with quote

Thanks Lexikos....
I have discover that the notify is not my problem, because I have same problems even disable all timers...

Thats my code:
Code:

#include MenuIcons.ahk
Gui, Add, ListView, +LV0x4400 x0 y152 h255 w566 Sort hwndhMyList vvMyList ggMyList AltSubmit Count500 , Col1|Co2|Col3|Col4|Col5

gMiLista:                               ; @ mouse click in the ListBox
   LV_GetText(id_seleccion, LV_GetNext("F"),2)
   ; some code to extract info from list
   if ( A_GuiControlEvent = "Normal" ) {
      Menu, MiMenu, add
      Menu, MiMenu, delete
      mix:=0
      Menu, MiMenu, add, %mode% to %c12% ,LABEL_Callto
      MI_SetMenuItemIcon("MiMenu",mix+=1,"phone.png.ico", 1, 16)
      if (cip_conectado=0)
         Menu, MiMenu, Disable, %mode% to %c12%
      }
      Menu, MiMenu, add, %mode% to %c13% ,LABEL_Callto
      MI_SetMenuItemIcon("MiMenu", mix+=1,"cellphone.png.ico", 1, 16)
      if (cip_conectado=0)
         Menu, MiMenu, Disable, %mode% to %c13%
      if (mix>0) {
         MI_SetMenuStyle("MiMenu", 0x4000000)
         MI_ShowMenu("MiMenu")
         }
      }
   if ( A_GuiControlEvent = "RightClick" )
      {
      ; Another menu...
      }
return

LABEL_Callto:
   ; code
return


I am using WXP SP3.
Back to top
segalion
Guest





PostPosted: Wed Mar 24, 2010 12:06 pm    Post subject: more info Reply with quote

I have more information.

I have logged messages at MI_OwnerDrawnMenuItemWndProc

Code:
MI_OwnerDrawnMenuItemWndProc(hwnd, Msg, wParam, lParam)
{
    static WM_DRAWITEM = 0x002B, WM_MEASUREITEM = 0x002C, WM_COMMAND = 0x111
    static ScriptHwnd
    Critical 500
;    if (Msg <> WM_MEASUREITEM and Msg <> WM_DRAWITEM and Msg <> 289 and Msg <> 287 and Msg <> 512)
;   log(5,"Msg=" . Msg . " wParam=" . wParam . " lParam=" . lParam)


And I can see that "sometimes", OS is not sending WM_COMMAND when I clic on a menu item. Sometimes I have to clic until 5 times to launch label.

I dont know why this is happen...
Back to top
segalion
Guest





PostPosted: Wed Mar 24, 2010 3:16 pm    Post subject: other problem Reply with quote

Other problem I have found is that keyboard is not working as standar menus (without icons), in witch you can navigate with keyboard and select with {enter}.

With MenuIcons, keyboards sometimes dont respond to arrow-keys, and you cant select with {Enter}.
Back to top
evgenuatam



Joined: 08 Apr 2010
Posts: 1
Location: under St. Petersburg

PostPosted: Thu Apr 08, 2010 8:23 pm    Post subject: Reply with quote

if menu is not created - library trow error.
im reqest to recreate function:
Code:

Mi_GetMenuHandle(menu_name)
{
    static   h_menuDummy   
    If !h_menuDummy
    {
        Menu, menuDummy, Add
        Menu, menuDummy, DeleteAll

        Gui, 99:Menu, menuDummy
        ; v2.2: Use LastFound method instead of window title. [Thanks animeaime.]
        Gui, 99:+LastFound

        h_menuDummy := DllCall("GetMenu", "uint", WinExist())

        Gui, 99:Menu
        Gui, 99:Destroy       
        ; v2.2: Return only after cleaning up. [Thanks animeaime.]
        if !h_menuDummy
            return 0
    }   
   Menu, menuDummy, UseErrorLevel
    Menu, menuDummy, Add, :%menu_name%
   if ErrorLevel
   {
      return 0
   }
    h_menu := DllCall( "GetSubMenu", "uint", h_menuDummy, "int", 0 )
    DllCall( "RemoveMenu", "uint", h_menuDummy, "uint", 0, "uint", 0x400 )
    Menu, menuDummy, Delete, :%menu_name%   
    return h_menu
}

exquse mi for may english - aim from russia
Back to top
View user's profile Send private message
flashkid



Joined: 25 Aug 2007
Posts: 110

PostPosted: Wed May 05, 2010 8:46 pm    Post subject: Reply with quote

Hi Lexikos, thanks for your functions, they are awesome Smile

But I've got a problem, when I integrate it into one of my scripts:
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Menu, MineSub, Add, Spam, Spam
Menu, MineSub, Add, Real, Real
Menu, Mine, Add, Spam-Mail, :MineSub
MI_SetMenuItemIcon("Mine",  1, "SpamMail_Icon.ico","",16)
MI_SetMenuStyle("Mine", 0x4000000)
Hotkey, RButton, RBLabel, On T3
Return
+ESC::ExitApp

+^!RButton::Hotkey, RButton, RBLabel, Off

RBLabel:
v++
ToolTip
If v = 2
{
   v = 0
   MI_ShowMenu("Mine")
   MsgBox
}
Else if v = 1
{
   ToolTip, Go, 100, 100
   Sleep, 300
   If v = 1
   {
      Click, Right
      v = 0
   }
}
Return

Spam-Mail:
Menu, MineSub, Show
Return

Real:
Send, myrealemail@email.com
Return

Spam:
Send, myfakemail@fakemail.com
Return

Why does it, after I double click RButton and then don't integrate with your menu, but simply click RButton again, instant send the RButton to the window and doesn't sleep 300ms? Can you try it out please, to understand whats the problem?

Thank you
Back to top
View user's profile Send private message
Yogui



Joined: 14 Jun 2008
Posts: 56
Location: Sydney, Australia

PostPosted: Thu Mar 17, 2011 5:21 am    Post subject: Rename and Change icon Reply with quote

Hi Lex,

I'm using your MI.ahk with AHK (non L) and found that large dinamic menus take some time to build.

I would like to be able to rename and change the icon of Menu items pref by Menu item position or Handle, So instead of rebuilding it I'll be modifying if and hopefully increase performance.

Is there any functions to do so?

Also when rebuilding a parent menu item it's children will loose the icons.

BTW, they look so nice when geting the right icons! Very Happy
_________________
Thanks, Yogui.
_____________________________
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Thu Mar 17, 2011 7:47 am    Post subject: Re: Rename and Change icon Reply with quote

Yogui wrote:
I would like to be able to rename and change the icon of Menu items pref by Menu item position or Handle, So instead of rebuilding it I'll be modifying if and hopefully increase performance.
You could just use Menu, Rename (using the old name) then reset the icon. If that isn't sufficient, perhaps MMenu will do the job. Or did you mean to reuse existing menu items for something entirely different? I doubt that'll help performance.
Quote:
Also when rebuilding a parent menu item it's children will loose the icons.
As a side-effect of deleting the parent menu, the native OS menu objects of its submenus are destroyed. AutoHotkey recreates the submenus as needed, but obviously knows nothing about the icons, so you must reset them. (However, note that AutoHotkey_L natively supports menu icons.)
Back to top
View user's profile Send private message Visit poster's website
fragman



Joined: 13 Oct 2009
Posts: 1199

PostPosted: Thu Mar 17, 2011 6:33 pm    Post subject: Reply with quote

I'm slightly amused by the thread title Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 7 of 9

 
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