Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ILButton() - image buttons with text, states, alignment


  • Please log in to reply
52 replies to this topic
  • Guests
  • Last active:
  • Joined: --
Oh forgot to mention, I'm on windows 7.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Yes but this is because the themed press animation doesn't introduce a visual offset, so it's correct if you ask me.

Laufer
  • Members
  • 54 posts
  • Last active: Sep 03 2013 05:59 PM
  • Joined: 16 Mar 2012
Can anyone tell me how can I make dll with graphical files? I tried this method but it doesn't work in ILButton. No pictures appears. For example I created this dll.
Whats wrong with this dll?

tmplinshi
  • Members
  • 245 posts
  • Last active: Mar 12 2015 02:29 PM
  • Joined: 06 Apr 2012

Hi~

 

How can I add the bmp image from the compiled exe itself? I had add the resource to AutoHotkeySC.bin using ResHacker.



Verdlin
  • Members
  • 256 posts
  • Last active: Apr 29 2016 06:46 PM
  • Joined: 21 Dec 2012

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.


Cragaha
  • Members
  • 265 posts
  • Last active: Jan 04 2016 02:24 AM
  • Joined: 19 Nov 2010
#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
    }


alvitawa
  • Members
  • 98 posts
  • Last active: Oct 14 2017 02:16 PM
  • Joined: 07 Feb 2013

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



Kiwi2703
  • Members
  • 10 posts
  • Last active: Mar 11 2015 08:31 PM
  • Joined: 02 Mar 2015

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:

57189.jpg

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? :(