[Class] ImageButton

Post your working scripts, libraries and tools
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

[Class] ImageButton

22 Dec 2013, 10:28

Prior version at old forum -> /board/topic/75064-function-createimagebutton-ahk-l/.

Well, here's a new version of an old script of mine. It has become more up-to-date than ever, because it can be 'misused' for somewhat 'Metro styled' buttons.

ImageButton_1_3.png
ImageButton_1_3.png (13.31 KiB) Viewed 13625 times


Change History


:arrow: Look at GitHub!
:arrow: Download from GitHub!

Note: To run the sample script, download both script files from the Sources folder and both pic files from Resources and store them all together into one folder. The script files should be saved as UTF-8 with BOM.
Last edited by just me on 07 Jun 2014, 02:05, edited 7 times in total.
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

22 Dec 2013, 14:43

Nice!
I usually create buttons through http://dabuttonfactory.com/, then use your Image2Include to convert them.
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

27 Dec 2013, 12:27

Update on 2013-12-27:

Inspired by tmplinshi's link, I revised the class and added options to create rounded and/or bicolored buttons. Thus I also had to change the number and types of parameters. Furthermore I added two methods to set the default colors for captions and backgrounds of rounded buttons.
fredchf
Posts: 23
Joined: 30 Sep 2013, 14:55

Re: [Class] ImageButton

27 Dec 2013, 17:24

Vielen Dank! :D
Diese Class kann man sicher mal gebrauchen...
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

28 Dec 2013, 07:49

just me wrote:Update on 2013-12-27:

Inspired by tmplinshi's link, I revised the class and added options to create rounded and/or bicolored buttons. Thus I also had to change the number and types of parameters. Furthermore I added two methods to set the default colors for captions and backgrounds of rounded buttons.

Thanks for this useful updates. :D
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

21 Feb 2014, 07:16

Hello just me, is it a easy work for you to add a border (with size and color)? :P It will be nice to have a border :)
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

21 Feb 2014, 07:27

Hello tmplinshi, it should be feasible. I'll try.
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

23 Feb 2014, 11:12

Update on 2014-02-23:

Added options for borders.
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

23 Feb 2014, 11:16

just me wrote:Update on 2014-02-23:

Added options for borders.

wow, amazing! :D Thank you so much!
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [Class] ImageButton

23 Feb 2014, 11:30

Sample script, when run, returns Invalid value for Mode in Options[" . Index . "]! :(
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

24 Feb 2014, 03:18

Hmmm, I've fixed the name in the #Include command of the sample script ex post yesterday.
Are you sure that you've updated the class script properly?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [Class] ImageButton

24 Feb 2014, 04:33

yes, i am using this class:

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

and this sample:

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

24 Feb 2014, 05:06

Change #Include Class_ImageButton_1_2.ahk to #Include Class_ImageButton.ahk in the sample and download Class_ImageButton.ahk again, please, if it doesn't help.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [Class] ImageButton

24 Feb 2014, 07:05

just me wrote:Change #Include Class_ImageButton_1_2.ahk to #Include Class_ImageButton.ahk in the sample and download Class_ImageButton.ahk again, please, if it doesn't help.

yes but i had saved the class as Class_ImageButton_1_2 before. i changed but still i get the same error. i should add however that in all cases after i dismiss the error message it then works. i.e. the error message is a nuisance but it does not stop the script or cause it to exit. :geek:
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

24 Feb 2014, 07:08

Would you please copy the whole message box?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [Class] ImageButton

24 Feb 2014, 10:14

MsgBox title is ImageButton Error Btn4:
Invalid value for StartColor in Options[1]!
I click OK and then it works! :geek:
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

24 Feb 2014, 11:19

Guest10 wrote:MsgBox title is ImageButton Error Btn4:
Invalid value for StartColor in Options[1]!
I click OK and then it works! :geek:

Copy Resources\PIC1.jpg and Resources\PIC2.jpg to script folder.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [Class] ImageButton

24 Feb 2014, 17:57

yeah, thanks, that was the ticket! :lol: :ugeek:
tmplinshi wrote:
Guest10 wrote:MsgBox title is ImageButton Error Btn4:
Invalid value for StartColor in Options[1]!
I click OK and then it works! :geek:

Copy Resources\PIC1.jpg and Resources\PIC2.jpg to script folder.
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

25 Feb 2014, 18:17

I took the script and sample from Github. I made sure to put the script in lib and named it exactly right. But when I try the sample program, I get this in a dialog box:
---------------------------
New AutoHotkey Script (431).ahk
---------------------------
Error at line 3.

#Include file "Class_ImageButton.ahk" cannot be opened.

The program will exit.
---------------------------
OK
---------------------------

I don't what I'm doing wrong. Are there specific instructions for downloading Class_ImageButton.ahk? Is there something else I need to download?
thanks
hunter99
Posts: 113
Joined: 20 Jan 2014, 17:57

Re: [Class] ImageButton

25 Feb 2014, 20:00

Hi danger, did you check Line 3 in the sample ahk script?
The orig had this #Include Class_ImageButton_1_1.ahk , if so remove the _1_1 at the end.
Should now work.
hunter

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bill and 23 guests