@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>
[Class] ImageButton - 1.5.00.00 - 20201230
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
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.
thanks
I didn't know thatIf you have moved Class_ImageButton.ahk to LIB folder, then you should use #Include <Class_ImageButton>
thanks
-
- Posts: 312
- Joined: 19 Nov 2013, 08:44
Re: [Class] ImageButton
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:
#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? ) but continued getting errors each time.
dangerdogL2121, did you get it working yet?
Thanks
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:
I also tried the following three replacements:dangerdogL2121 wrote:---------------------------
Error at line 3.
#Include file "Class_ImageButton.ahk" cannot be opened.
The program will exit.
---------------------------
#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? ) 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.
"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.
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
No, I haven't got it working yet.dangerdogL2121, did you get 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.
I didn't know you could download a zip from GitHub until you just said so! 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.2) Clicked [Download ZIP] button to download Class_ImageButton-master.zip
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
Re: [Class] ImageButton
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.
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
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
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
Code: Select all
#Include
thanks
Re: [Class] ImageButton
?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.
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
A new installation of AHK and no more of the blank parameter problem!
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
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
-
- Posts: 312
- Joined: 19 Nov 2013, 08:44
Re: [Class] ImageButton
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?
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
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
Gui, Destroy
Gui, +AlwaysOnTop
Gui, -Caption +LastFound
Gui, Add, Button, x2 y2 w120 h24, Test1
Gui, Add, Button, x124 y2 w120 h24, Test2
Gui, Add, Button, x246 y2 w120 h24, Test3
Gui, Show, x500 y600 w368 h28, Noactivate
Return
ButtonTest1:
MsgBox You clicked the Test1 button.
Return
ButtonTest2:
MsgBox You clicked the Test2 button.
Return
ButtonTest3:
MsgBox You clicked the Test3 button.
Return
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.
"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.
Re: [Class] ImageButton
Code: Select all
#NoEnv
#Include Class_ImageButton.ahk ; you have to include the class, it's expected to be in the script folder
Gui, Destroy
Gui, +AlwaysOnTop
Gui, -Caption +LastFound
Gui, Add, Button, x2 y2 w120 h24 hwndHBTN1, Test1 ; added hwnd option
Gui, Add, Button, x124 y2 w120 h24 hwndHBTN2, Test2 ; added hwnd option
Gui, Add, Button, x246 y2 w120 h24 hwndHBTN3, Test3 ; added hwnd option
; Test1 button: unicolored = 0, - background color = "Lime", text color = "Maroon"
Opt1 := [0, "Lime", , "Maroon"]
ImageButton.Create(HBTN1, Opt1)
; Test2 button: unicolored = 0, - background color = "Yellow", text color = "Navy"
Opt1 := [0, "Yellow", , "Navy"]
ImageButton.Create(HBTN2, Opt1)
; Test3 button: unicolored = 0, - background color = "Red", text color = "Lime"
Opt1 := [0, "Red", , "Lime"]
ImageButton.Create(HBTN3, Opt1)
Gui, Show, x500 y600 w368 h28, Noactivate
Return
ButtonTest1:
MsgBox You clicked the Test1 button.
Return
ButtonTest2:
MsgBox You clicked the Test2 button.
Return
ButtonTest3:
MsgBox You clicked the Test3 button.
Return
Re: [Class] ImageButton
*released v 1.3.00.00*
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
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
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
Re: [Class] ImageButton
Hi danger, you can take a look at this . Little add to just me's test script.
hunter
Code: Select all
#NoEnv
#Include <Class_ImageButton> ; you have to include the class, it's expected to be in the script folder
Gui, Destroy
Gui, +AlwaysOnTop
Gui, -Caption +LastFound
Gui, Color, F0F0F0, F0F0F0 ;added Mar 3,2014 hunter99 tranparent test. The F0F0F0 is the MSWindows default color
WinSet, TransColor, F0F0F0 ;added Mar 3,2014 hunter99 tranparent test
Gui, Add, Button, x2 y2 w120 h24 hwndHBTN1, Test1 ; added hwnd option
Gui, Add, Button, x124 y2 w120 h24 hwndHBTN2, Test2 ; added hwnd option
Gui, Add, Button, x246 y2 w120 h24 hwndHBTN3, Test3 ; added hwnd option
; Test1 button: unicolored = 0, - background color = "Lime", text color = "Maroon"
Opt1 := [0, "Lime", , "Maroon", 22] ;test to make round corners, ", 22" added Mar 3,2014 hunter99
ImageButton.Create(HBTN1, Opt1)
; Test2 button: unicolored = 0, - background color = "Yellow", text color = "Navy"
Opt1 := [0, "Yellow", , "Navy", 22] ;test to make round corners, ", 22" added Mar 3,2014 hunter99
ImageButton.Create(HBTN2, Opt1)
; Test3 button: unicolored = 0, - background color = "Red", text color = "Lime"
Opt1 := [0, "Red", , "Lime", 22] ;test to make round corners, ", 22" added Mar 3,2014 hunter99
ImageButton.Create(HBTN3, Opt1)
Gui, Show, x500 y600 w368 h28, Noactivate
Return
ButtonTest1:
MsgBox You clicked the Test1 button.
Return
ButtonTest2:
MsgBox You clicked the Test2 button.
Return
ButtonTest3:
MsgBox You clicked the Test3 button.
Return
GuiEscape: ;added Mar 3,2014 hunter99
ExitApp
return
Re: [Class] ImageButton
Has this been answered by the post of hunter99?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.
Because there are six button states.Question2: Why does the function need to use six arrays?
What do you want to achieve with overlapped buttons?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
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
Leave the 7th parameter blank or omitted. Thank you hunter99Question: 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.
Ok.Because there are six button states.Question2: Why does the function need to use six arrays?
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.What do you want to achieve with overlapped buttons?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
Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?
thanks
Re: [Class] ImageButton
I'm not sure what you're talking about.Leave the 7th parameter blank or omitted. Thank you hunter99
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.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 ...
It might help to use GuiControl, MoveDraw, ....... for a time even after the top button has been moved off the lower button.
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.Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
If you leave the seventh item(BorderColor) of the array empty then the background color of the border will be transparent.\I'm not sure what you're talking about.Leave the 7th parameter blank or omitted. Thank you hunter99
One reason would be if someone wanted to change the border color of a button without coloring the interior of the button.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.Question: Is it possible to have a border around a button without setting its color in StartColor or TargetColor?
thanks
Last edited by dangerdogL2121 on 05 Mar 2014, 11:07, edited 2 times in total.
Re: [Class] ImageButton
Still not sure. If you leave BorderColor empty, no border will be drawn at all.If you leave the seventh item(BorderColor) of the array empty then the background color of the border will be transparent.
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.One reason would be if someone wanted to change the border color of a button without color and interior or the button.
I'll think about it.
- dangerdogL2121
- Posts: 173
- Joined: 01 Oct 2013, 23:11
Re: [Class] ImageButton
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
If GuiColor is blank, the border is transparent.
Also, I fixed a typo in my most recent post.
thanks
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 177 guests