[Class] ImageButton

Post your working scripts, libraries and tools
tmplinshi
Posts: 1242
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

25 Feb 2014, 20:45

@dangerdogL2121
Put Class_ImageButton.ahk and Sample.ahk in the same folder.

If you have moved Class_ImageButton.ahk to LIB folder, then you should use #Include <Class_ImageButton>
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

25 Feb 2014, 21:22

I put Class_ImageButton.ahk and Sample.ahk in the same folder, a folder named Image button and is empty except for the scripts. It still gives me the same error. Maybe my version AHK is out of date or something.
If you have moved Class_ImageButton.ahk to LIB folder, then you should use #Include <Class_ImageButton>

I didn't know that :P
thanks
WeThotUWasAToad
Posts: 198
Joined: 19 Nov 2013, 08:44

Re: [Class] ImageButton

26 Feb 2014, 15:13

Hello,

I got the same result as dangerdogL2121:

------------------------------------------------------------
1) Clicked the link in the first post of this thread [Download from GitHub and enjoy!] which took me to https://github.com/AHK-just-me/Class_ImageButton

2) Clicked [Download ZIP] button to download Class_ImageButton-master.zip

3) Moved zip file into new folder: C:\Users\Name\My Folders\AHK\ImageButton_2014-02-26

4) Extracted all which left me with two .ahk files:

C:\Users\Name\My Folders\AHK\ImageButton_2014-02-26\Class_ImageButton-master\Class_ImageButton-master\Sources\Sample.ahk
and
C:\Users\Name\My Folders\AHK\ImageButton_2014-02-26\Class_ImageButton-master\Class_ImageButton-master\Sources\Class_ImageButton.ahk
------------------------------------------------------------

That's as far as I got though:

a) Double-clicking either file does nothing
b) Searched both files for "_1_1" but came up empty
c) Moved main file to: C:\Program Files\AutoHotkey\Lib\Class_ImageButton.ahk
d) Then tried to run Sample file again and got the same error as dangerdogL2121:

dangerdogL2121 wrote:---------------------------
Error at line 3.

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

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


I also tried the following three replacements:

#Include Class_ImageButton.ahk replaced with #Include <Class_ImageButton>
#Include Class_ImageButton.ahk replaced with #Include <Class_ImageButton>.ahk
#Include Class_ImageButton.ahk replaced with #Include <Class_ImageButton.ahk>

(Can you tell I don't know what the heck I'm doing? :roll: ) but continued getting errors each time.

dangerdogL2121, did you get it working yet?

Thanks :)
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word — it never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

27 Feb 2014, 00:22

dangerdogL2121, did you get it working yet?

No, I haven't got it working yet.

Sorry hunter99, I didn't read your post until just now.
I downloaded the Sample.ahk and ImageButton.ahk after just me put out the fixed version, so the _1_1 in the #Include was not the problem.

2) Clicked [Download ZIP] button to download Class_ImageButton-master.zip

I didn't know you could download a zip from GitHub until you just said so! :P I always copy the code and paste it in a file named correctly. However, I didn't see any change in the error by using the zip version.

I tried changing the file Class_ImageButton.ahk to ImageButton.ahk and the #Include as well but that didn't help either.
I'm glad I'm not the only one having this problem.
thanks
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

27 Feb 2014, 00:46

Classes are not library compatible as yet. You always have to #Include them manually. If you've stored Class_ImageButton.ahk in one of the library directories, #Include <Class_ImageButton> should work; at least it does for me. If you've stored the class and the sample script in the same folder, you need #Include Class_ImageButton.ahk instead. I cannot reproduce the error here.
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: [Class] ImageButton

27 Feb 2014, 00:50

I added

and it worked.

Hubert
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

27 Feb 2014, 01:24

I changed #Include Class_ImageButton.ahk to #Include <Class_ImageButton> and it appears to have worked.
Now I get a new error:




---------------------------
Sample.ahk
---------------------------
Error: Blank parameter

Specifically: [0, 0xCF0000, , "White", 22, , "Yellow", 2]

Line#
017: GuiColor := "Silver"
018: Gui,Margin,50,20
019: Gui,Font,s10
020: Gui,Color,%GuiColor%
021: ImageButton.SetGuiColor(GuiColor)
023: Gui,Add,Button,w200,Common Button
025: Gui,Add,Button,vBT1 w200 hwndHBT1,Button 1
Line 2
---> 026: Opt1 := [0, 0xCF0000, , "White", 22, , "Yellow", 2]
027: Opt2 := [ , "Red"]
028: Opt5 := [ , , ,"Gray"]
029: if !ImageButton.Create(HBT1, Opt1, Opt2, , , Opt5)
030: MsgBox,0,ImageButton Error Btn1,ImageButton.LastError
032: Gui,Add,Button,vBT2 w200 h30 hwndHBT2,Button 2
033: Opt1 := [1, 0xF0F0F0, 0xC0F0FF, "Black", , , "Lime", 1]
034: Opt2 := {2: 0xE0E0E0, 3: 0xB0E0FF, 4: "Black"}

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

What does this mean? I can see that there's a blank parameter, but if you don't have that problem, it probably has to do with the .
thanks
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

27 Feb 2014, 01:29

Recent Changes wrote:1.1.12.00 - August 14, 2013
Optional parameters can be omitted by writing two consecutive commas, as in InStr(a, b,, 2). Unlike previous versions, this now works for objects (including COM objects) and built-in functions. [a,,b] can be used to create a sparse array.
?
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

27 Feb 2014, 02:07

A new installation of AHK and no more of the blank parameter problem! :P

Now, I getting the same problem that Guest 10 had the message box that says
---------------------------
ImageButton Error Btn4
---------------------------
Invalid value for StartColor in Options[1]!
---------------------------
OK
---------------------------

Except that I did copy PIC1.jpg and PIC2.jpg into the script folder like Guest 10 did and the error box still appears and the script still works except for that.
thanks and nice buttons
WeThotUWasAToad
Posts: 198
Joined: 19 Nov 2013, 08:44

Re: [Class] ImageButton

27 Feb 2014, 16:40

I also updated AHK (from v1.1.11.01 to v1.1.14.03) and it fixed the issue for me as well.

However, there are parts of the, "How to use" steps which I don't understand so my next hurdle is being able to actually apply Class_ImageButton to a GUI and its buttons.

It would help me a lot to see an actual script with modified buttons. So for example, could you show how you would assign different colors to each of the three buttons in the following simple GUI script?

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


By the way, as I mentioned earlier, my Class_ImageButton.ahk file is here:
C:\Users\Name\My Folders\AHK\ImageButton_2014-02-26\Class_ImageButton-master\Class_ImageButton-master\Sources\Class_ImageButton.ahk

Do I need to save the script containing the GUI in that same folder or can it be saved anywhere?

Thanks
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word — it never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

28 Feb 2014, 05:23

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

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

Re: [Class] ImageButton

28 Feb 2014, 13:01

*released v 1.3.00.00*
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

02 Mar 2014, 08:30

Question: Is it possible to cut off or make transparent the area past the borders of buttons, the corners? I might have missed it in the How to Use page.

Question2: Why does the function need to use six arrays?

Also it is possible to keep overlapping button from flickering or taking the image from the button on top of the overlap? Is this possible with an attribute in Class_ImageButton.ahk?
thanks
hunter99
Posts: 113
Joined: 20 Jan 2014, 17:57

Re: [Class] ImageButton

03 Mar 2014, 00:14

Hi danger, you can take a look at this . Little add to just me's test script.

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



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

Re: [Class] ImageButton

03 Mar 2014, 09:16

dangerdogL2121 wrote:Question: Is it possible to cut off or make transparent the area past the borders of buttons, the corners? I might have missed it in the How to Use page.
Has this been answered by the post of hunter99?

Question2: Why does the function need to use six arrays?
Because there are six button states.

Also it is possible to keep overlapping button from flickering or taking the image from the button on top of the overlap? Is this possible with an attribute in Class_ImageButton.ahk?
thanks
What do you want to achieve with overlapped buttons?
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

03 Mar 2014, 13:16

Question: Is it possible to cut off or make transparent the area past the borders of buttons, the corners? I might have missed it in the How to Use page.

Leave the 7th parameter blank or omitted. Thank you hunter99

Question2: Why does the function need to use six arrays?

Because there are six button states.

Ok.

Also it is possible to keep overlapping button from flickering or taking the image from the button on top of the overlap? Is this possible with an attribute in Class_ImageButton.ahk?
thanks

What do you want to achieve with overlapped buttons?

If a button is placed on top of another button with GuiControl, the pixels on the lower button might be changed to the pixels on the top button for a time even after the top button has been moved off the lower button.

Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?
thanks
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

04 Mar 2014, 01:02

Leave the 7th parameter blank or omitted. Thank you hunter99
I'm not sure what you're talking about.

If a button is placed on top of another button with GuiControl, the pixels on the lower button might be changed to the pixels on the top button ...
That's caused by the order in which the system is drawing the controls. It might help to disable the lower button while the other is on top of it.
... for a time even after the top button has been moved off the lower button.
It might help to use GuiControl, MoveDraw, ....

Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?
Currently not, because the whole button is represented by one image per state and the border is part of the image. It might be enabled by storing the last options in the instance and adding a Change() method. But I'll have to have a good reason to do it.
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

04 Mar 2014, 22:30

\
Leave the 7th parameter blank or omitted. Thank you hunter99

I'm not sure what you're talking about.

If you leave the seventh item(BorderColor) of the array empty then the background color of the border will be transparent.

Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?

Currently not, because the whole button is represented by one image per state and the border is part of the image. It might be enabled by storing the last options in the instance and adding a Change() method. But I'll have to have a good reason to do it.

One reason would be if someone wanted to change the border color of a button without coloring the interior of the button.
thanks
Last edited by dangerdogL2121 on 05 Mar 2014, 11:07, edited 2 times in total.
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

05 Mar 2014, 04:51

If you leave the seventh item(BorderColor) of the array empty then the background color of the border will be transparent.
Still not sure. If you leave BorderColor empty, no border will be drawn at all. :roll:

One reason would be if someone wanted to change the border color of a button without color and interior or the button.
Well, for any change of any aspect of an image button all images as well as the image list have to be recreated. This will cost some time and CPU power, and may result in flickering.
I'll think about it.
User avatar
dangerdogL2121
Posts: 173
Joined: 01 Oct 2013, 23:11

Re: [Class] ImageButton

05 Mar 2014, 11:14

Sorry, I wrote the wrong thing.
If GuiColor is blank, the border is transparent.

Also, I fixed a typo in my most recent post.
thanks

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 16 guests