AutoHotkey Community

It is currently May 27th, 2012, 6:31 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 132 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next
Author Message
PostPosted: March 18th, 2010, 3:22 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject: thanks
PostPosted: March 18th, 2010, 9:45 am 
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....


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 1:32 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks Lexikos
PostPosted: March 22nd, 2010, 1:33 pm 
Im going to use your recomendation with file loop to run png2ico option...

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

"Meus respeitos"


Report this post
Top
  
Reply with quote  
 Post subject: Hello Lexikos
PostPosted: March 23rd, 2010, 7:00 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 23rd, 2010, 7:13 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 9:23 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks Lexikos
PostPosted: March 24th, 2010, 11:08 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject: more info
PostPosted: March 24th, 2010, 1:06 pm 
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...


Report this post
Top
  
Reply with quote  
 Post subject: other problem
PostPosted: March 24th, 2010, 4:16 pm 
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}.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2010, 9:23 pm 
Offline

Joined: April 8th, 2010, 9:11 pm
Posts: 1
Location: under St. Petersburg
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 9:46 pm 
Offline

Joined: August 25th, 2007, 9:25 pm
Posts: 110
Hi Lexikos, thanks for your functions, they are awesome :)

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Rename and Change icon
PostPosted: March 17th, 2011, 6:21 am 
Offline

Joined: June 14th, 2008, 7:47 pm
Posts: 56
Location: Sydney, Australia
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! :D

_________________
Thanks, Yogui.
_____________________________


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 17th, 2011, 8:47 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2011, 7:33 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I'm slightly amused by the thread title :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 132 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Yahoo [Bot] and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group