ILButton() - image buttons with text, states, alignment
Whats wrong with this dll?
Hi~
How can I add the bmp image from the compiled exe itself? I had add the resource to AutoHotkeySC.bin using ResHacker.
Bug report: passing in absolute paths to ILButton result in a blank image because of StringSplit command. I.e. C:\AutoHotkey\image.jpg
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
#SingleInstance force gui, -sysmenu gui, add, button, w200 h70 gguiClose hwndhBtn, Close button_il(hBtn, "shell32.dll", 131, 48, 48, "left", "10") gui, show,,button_il return guiClose: exitApp button_il(pHBtn, pFile, pIndex:=1, pW:=16, pH:=16, pAlign="middle", pMargin="1,1,1,1"){ /* modifed by Nazzal pAlign: 1 = right 2 = top 3 = bottom 4 = middle 5 = left pMargin: left,top,right,bottom */ static i = 0 i++ hIL := DllCall("comctl32.dll\ImageList_Create","int",pW,"int",pH,"uint",0x21,"int",1,"int", 1) DllCall("PrivateExtractIcons","str",pFile,"int",pIndex-1,"int",pW,"int",pH,"uint*",HICON,"uint*",0,"uint",1,"uint",0) ifEqual,HICON,0,return 0 DllCall("ImageList_AddIcon", "Ptr", hIL, "Ptr", hIcon) DllCall("DestroyIcon", "Ptr", hicon) VarSetCapacity(struct%i%, A_PtrSize + (5 * 4) + (A_PtrSize - 4), 0) NumPut(hIL, struct%i%, 0, "Ptr") Loop, Parse, pMargin, `, NumPut(A_LoopField, struct%i%, A_PtrSize + ((A_Index - 1) * 4), "Int") pAlign := pAlign = "right" ? 1 : (pAlign = "top" ? 2 : (pAlign = "bottom" ? 3 : (pAlign = "middle" ? 4 : 5))) NumPut(pAlign, struct%i%, A_PtrSize + (4 * 4), "UInt") Result := DllCall("SendMessage", "uint", pHBtn, "uint", 0x1602, "uint", 0, "uint", &struct%i%) ifEqual,A_OSVersion,WIN_XP,sleep 1 ; XP workaround Return Result }
Why doesn't this work?
Gui, Add, Button, xm w174 h48 vStates hwndhBtn, pushbuttonstates ILButton(hBtn, "img.ico:0", 32, 32, 0)
I have the img.ico in the same directory. Copying
Gui, Add, Button, xm w174 h48 vStates hwndhBtn, pushbuttonstatesILButton(hBtn, "user32.dll:0|:1|:2|:3|:4|:5", 32, 32, 0, "16,1,-16,1")
from the example script just worked, but I can't manage to use my own image files. Also tryed bmp
Thanks for the script, it's really good!
Except I have a little problem with it in one instance. I have a function that creates a number of buttons and I need them to have a background image. However, when I use this script, this happens:
For the first three buttons it placed the image with a weird offset, while the rest of the buttons are fine. I have no idea what may cause this, because the first three buttons are not special in any way, they are generated just like the rest of them.
Any help please?