[Class] ImageButton - 1.5.00.00 - 20201230
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Thanks for the update!
-
- Posts: 26
- Joined: 15 Sep 2020, 03:51
- Location: Germany
- Contact:
Re: [Class] ImageButton - 1.5.00.00 - 20201230
It seems, I can't get it to work to make render Image inside the Button. Can I use specific Image Paths for ImageButtons?
I need an Tutorial how to implement the Images.
I need an Tutorial how to implement the Images.
Re: [Class] ImageButton - 1.5.00.00 - 20201230
README.mdGamesOfFreak wrote:I need an Tutorial how to implement the Images.
-
- Posts: 26
- Joined: 15 Sep 2020, 03:51
- Location: Germany
- Contact:
Re: [Class] ImageButton - 1.5.00.00 - 20201230
I found myself how I it works!
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@just me How I could get the text of the button control?
I tried using GuiControlGet and ControlGetText, but the output variable always returns blank.
The same code in Button2 that is not using the ImageButton class, does return the text correctly.
edit:
Also, I would like to thank you, as always amazing scripts!
Code: Select all
Gui, Add, Button, w60 h18 hwndB1 vB1, B1
Opt1 := {0:1, 1: 0x9b451d, 2:0x9b451d, 3:0x9b451d, 4:"White", 5:8, 6:0x211b18}
; opt2: hover
Opt2 := {2: 0xe6b553, 3:0xe6b553, 4: "White"}
; opt3: click
Opt3 := {4: "White"}
If !ImageButton.Create(B1, Opt1, Opt2, Opt3)
MsgBox, 0, ImageButton Error Btn2, % ImageButton.LastError
; -----------------------------------
GuiControlGet, hwnd, Hwnd , B1
GuiControlGet, text,,B1
ControlGetText, text2, , ahk_id %hwnd%
; blank output here ->
fileappend hwnd:%hwnd% text:%text% text2: %text2%`n,*
; -----------------------------------
Gui, Add, Button, w60 h18 hwndB2 vB2, B2
; -----------------------------------
GuiControlGet, hwnd, Hwnd , B2
GuiControlGet, text,,B2
ControlGetText, text2, , ahk_id %hwnd%
fileappend hwnd:%hwnd% text:%text% text2: %text2%`n,*
; -----------------------------------
gui,show
The same code in Button2 that is not using the ImageButton class, does return the text correctly.
edit:
Also, I would like to thank you, as always amazing scripts!
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@c7aesa7r,
because of problems on Win XP (and maybe later versions) the class containsto remove the button's caption. You might try to comment it out.
because of problems on Win XP (and maybe later versions) the class contains
Code: Select all
; Hide buttons's caption
ControlSetText, , , ahk_id %HWND%
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@just me Thanks, it does work.
I'm also using your script CtlColorStatic
I'm also using your script CtlColorStatic
But sometimes the controls lose all the colors and style, and when i click for example a tab, it does restore the colors, have you seen this before?
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@just me i tried to modify your function a bit to add support to multi color text inside a button, its almost 'perfect', current problem is to measure the real font size and calculate the space between the texts.
I have added after:
Code: Select all
; Draw the text
DllCall("Gdiplus.dll\GdipDrawString", "Ptr", PGRAPHICS, "WStr", BtnCaption, "Int", -1
, "Ptr", PFONT, "Ptr", &RECT, "Ptr", HFORMAT, "Ptr", PBRUSH)
Code: Select all
if (oCaption := Option.caption)
{
; get the current button font and size
GetFont := GetFont(hwnd)
fname := % getfont.fontname
fsize := % getfont.size
fileappend > font:%fname%`nsize:%fsize% hwnd:%hwnd% `n`n,*
StringWidth := StringWidth(BtnCaption,GetFont.FontName,GetFont.Size)
_left += StringWidth
;fileappend StringWidth:%StringWidth% _left:%_left% `n`n,*
for textColor,text in oCaption
{
; add space between the text
BtnCaption := " "
BtnCaption .= text
; try to measure the current caption size
StringWidth := StringWidth(BtnCaption,GetFont.FontName,GetFont.Size)
NumPut( _left , RECT, 0, "Float")
_left += StringWidth
;Len := Round(StringWidth/StrLen(BtnCaption))
NumPut(BtnH, RECT, 12, "Float")
DllCall("Gdiplus.dll\GdipCreateSolidFill", "UInt", textColor, "PtrP", PBRUSH)
; Draw the text
DllCall("Gdiplus.dll\GdipDrawString", "Ptr", PGRAPHICS, "WStr", BtnCaption, "Int", -1
, "Ptr", PFONT, "Ptr", &RECT, "Ptr", HFORMAT, "Ptr", PBRUSH)
}
}
; -----------------------------------------
; FUNCTIONS
StringWidth(String, Font:="", FontSize:=10)
{
;fileappend font -> %Font% `n,*
Gui,StringWidth: -DPIScale
Gui StringWidth:Font, s%FontSize%, %Font%
Gui StringWidth:Add, Text, R1, %String%
GuiControlGet T, StringWidth:Pos, Static1
Gui StringWidth:Destroy
return TW
}
GetFont(hWnd) {
static WM_GETFONT := 0x31
hFont := DllCall("SendMessage", "Ptr", hWnd, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
if !hFont {
Gui, %hWnd%: Add, Text, xp yp wp hp Hidden hwndhText
hFont := DllCall("SendMessage", "Ptr", hText, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
DllCall("DestroyWindow", "Ptr", hText)
}
sizeLF := DllCall("GetObject", "Ptr", hFont, "Int", 0, "Ptr", 0)
VarSetCapacity(LOGFONT, sizeLF, 0)
DllCall("GetObject", "Ptr", hFont, "Int", sizeLF, "Ptr", &LOGFONT)
Size :=-NumGet(LOGFONT, "Int")*72//A_ScreenDPI
Weight := NumGet(LOGFONT, 16, "Int")
Italic := NumGet(LOGFONT, 20, "Char")
Underline := NumGet(LOGFONT, 21, "Char")
Strike := NumGet(LOGFONT, 22, "Char")
Quality := NumGet(LOGFONT, 26, "Char")
FontName := StrGet(&LOGFONT + 28)
res := {}
for k, v in ["Size", "Weight", "Italic", "Underline", "Strike", "Quality", "FontName"]
res[v] := %v%
Return res
}
; -----------------------------------------
Code: Select all
gui,font,s22,consolas
gui,add,button,w400 h20 hwndHwnd left,button test
Opt1 := { 1:5, 2:0x070707, caption:{ 0xFF1cc400:"some", 0xFFff0000:"text" }, 3:0x070707, 4:0xffffff, 7:0x070707 }
ImageButton.Create(hwnd,Opt1)
gui,show,h200
return
Spoiler
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Hi @c7aesa7r,
your approach would work only for left aligned singe line buttons, if at all. Currently I'm not interested in multi-coulored button text for Class_ImageButton. If you want to carry on, I recommend to use GDI+ functions for the measuring (e.g. Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)).
your approach would work only for left aligned singe line buttons, if at all. Currently I'm not interested in multi-coulored button text for Class_ImageButton. If you want to carry on, I recommend to use GDI+ functions for the measuring (e.g. Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)).
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Code: Select all
ms:= Gdip_MeasureString(pGraphics, BtnCaption, hFont, hFormat, ByRef RectF)
fileappend ms:%ms% `n`n,*
Also when I call the function it not draw the coloured text anymore, I'm calling the code above just after
Code: Select all
DllCall("Gdiplus.dll\GdipDrawString"
Got it now, I need to pass PFont and not hFont in that parameter
-
- Posts: 122
- Joined: 06 Mar 2020, 21:48
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@just me is possible to also edit dropdownlist like the things your button lib does?
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@fabricio234,
that would be another task because the button of a DDL needs to change it's caption with every new selection.
that would be another task because the button of a DDL needs to change it's caption with every new selection.
-
- Posts: 122
- Joined: 06 Mar 2020, 21:48
Re: [Class] ImageButton - 1.5.00.00 - 20201230
@just me do you have an example? doesn't matter the caption, just would like to see from where to start
-
- Posts: 122
- Joined: 06 Mar 2020, 21:48
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Done:
Do you know if/how to change the border-radius of this white rectangle? I know how to change the text and background color would like to set it to a round border like the button.
I draw a dropdown under the button and when i hit the button it calls the dropdown. Do you know if/how to change the border-radius of this white rectangle? I know how to change the text and background color would like to set it to a round border like the button.
-
- Posts: 188
- Joined: 08 Jul 2019, 05:37
- Contact:
Re: [Class] ImageButton - 1.5.00.00 - 20201230
can any body give a direction on how to make this possible with image button
i need to change button caption , but how?
i need to change button caption , but how?
Code: Select all
Gui +ToolWindow
Gui, Add, Button, w100 h25 gStartStop vButtonText, Start
Gui, Show, , Test
Return
StartStop:
GuiControlGet, ButtonText
If ( ButtonText = "Start" )
{
GuiControl,, ButtonText, Stop
GoSub, Start
}
Else
{
GuiControl,, ButtonText, Start
GoSub, Stop
}
Return
Start:
Return
Stop:
Return
GuiClose:
ExitApp
GuiContextMenu:
reload
-
- Posts: 188
- Joined: 08 Jul 2019, 05:37
- Contact:
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Figured that out, but i would loose the option of text color from image button class.
Now i need to figure out a way to change button text color.
Now i need to figure out a way to change button text color.
Re: [Class] ImageButton - 1.5.00.00 - 20201230
Example of Bootstrap like Buttons
Code: Select all
#NoEnv
SetBatchLines, -1
; Class ImageButton by just me
; https://www.autohotkey.com/boards/viewtopic.php?t=1103
#Include Class_ImageButton.ahk
; for v1.5 add UseGDIP.ahk or Include them into Class_ImageButton.ahk
; #Include UseGDIP.ahk
Gui, Margin, 20, 20
Gui, Font, s11 normal, Segoe UI
; ---------------------------------------------------------------------------------------
Gui, Add, Button, xm ym w80 h24 hWndhBtn11, % "Critical"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ; normal
, [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 1] ; hover
, [0, 0x80E27C79, , , 0, , 0x80D43F3A, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ]
ImageButton.Create(hBtn11, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn12, % "Warning"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ; normal
, [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 1] ; hover
, [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ]
ImageButton.Create(hBtn12, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn13, % "Success"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ; normal
, [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 1] ; hover
, [0, 0x8091CF91, , , 0, , 0x805CB85C, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ]
ImageButton.Create(hBtn13, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn14, % "Info"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ; normal
, [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 1] ; hover
, [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ]
ImageButton.Create(hBtn14, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn21, % "Critical"
IBBtnStyles := [ [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 1] ; normal
, [0, 0x80E27C79, , , 0, , 0x80D43F3A, 1] ; hover
, [0, 0x80D43F3A, , , 0, , 0x80D43F3A, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ]
ImageButton.Create(hBtn21, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn22, % "Warning"
IBBtnStyles := [ [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 1] ; normal
, [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 1] ; hover
, [0, 0x80F0AD4E, , , 0, , 0x80F0AD4E, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ]
ImageButton.Create(hBtn22, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn23, % "Success"
IBBtnStyles := [ [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 1] ; normal
, [0, 0x8091CF91, , , 0, , 0x805CB85C, 1] ; hover
, [0, 0x805CB85C, , , 0, , 0x805CB85C, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ]
ImageButton.Create(hBtn23, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn24, % "Info"
IBBtnStyles := [ [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 1] ; normal
, [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 1] ; hover
, [0, 0x8046B8DA, , , 0, , 0x8046B8DA, 1] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ]
ImageButton.Create(hBtn24, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, xm y+20 w80 h24 hWndhBtn31, % "Critical"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; normal
, [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; hover
, [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ]
ImageButton.Create(hBtn31, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn32, % "Warning"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; normal
, [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; hover
, [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ]
ImageButton.Create(hBtn32, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn33, % "Success"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; normal
, [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; hover
, [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ]
ImageButton.Create(hBtn33, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn34, % "Info"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; normal
, [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; hover
, [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ]
ImageButton.Create(hBtn34, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn41, % "Critical"
IBBtnStyles := [ [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; normal
, [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; hover
, [0, 0x80D43F3A, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ]
ImageButton.Create(hBtn41, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn42, % "Warning"
IBBtnStyles := [ [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; normal
, [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; hover
, [0, 0x80F0AD4E, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ]
ImageButton.Create(hBtn42, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn43, % "Success"
IBBtnStyles := [ [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; normal
, [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; hover
, [0, 0x805CB85C, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ]
ImageButton.Create(hBtn43, IBBtnStyles*)
Gui, Add, Button, x+20 yp w80 h24 hWndhBtn44, % "Info"
IBBtnStyles := [ [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; normal
, [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; hover
, [0, 0x8046B8DA, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ]
ImageButton.Create(hBtn44, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, xm y+20 w200 h40 hWndhBtn51, % "Critical"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ; normal
, [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 2] ; hover
, [0, 0x80E27C79, , , 0, , 0x80D43F3A, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ]
ImageButton.Create(hBtn51, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn52, % "Warning"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ; normal
, [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 2] ; hover
, [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ]
ImageButton.Create(hBtn52, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn53, % "Success"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ; normal
, [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 2] ; hover
, [0, 0x8091CF91, , , 0, , 0x805CB85C, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ]
ImageButton.Create(hBtn53, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn54, % "Info"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ; normal
, [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 2] ; hover
, [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ]
ImageButton.Create(hBtn54, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, xm y+20 w200 h40 hWndhBtn61, % "Critical"
IBBtnStyles := [ [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 2] ; normal
, [0, 0x80E27C79, , , 0, , 0x80D43F3A, 2] ; hover
, [0, 0x80D43F3A, , , 0, , 0x80D43F3A, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ]
ImageButton.Create(hBtn61, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn62, % "Warning"
IBBtnStyles := [ [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 2] ; normal
, [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 2] ; hover
, [0, 0x80F0AD4E, , , 0, , 0x80F0AD4E, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ]
ImageButton.Create(hBtn62, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn63, % "Success"
IBBtnStyles := [ [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 2] ; normal
, [0, 0x8091CF91, , , 0, , 0x805CB85C, 2] ; hover
, [0, 0x805CB85C, , , 0, , 0x805CB85C, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ]
ImageButton.Create(hBtn63, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn64, % "Info"
IBBtnStyles := [ [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 2] ; normal
, [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 2] ; hover
, [0, 0x8046B8DA, , , 0, , 0x8046B8DA, 2] ; pressed
, [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ]
ImageButton.Create(hBtn64, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Add, Button, xm y+20 w200 h40 hWndhBtn71, % "Critical"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; normal
, [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; hover
, [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ]
ImageButton.Create(hBtn71, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn72, % "Warning"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; normal
, [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; hover
, [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ]
ImageButton.Create(hBtn72, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn73, % "Success"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; normal
, [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; hover
, [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ]
ImageButton.Create(hBtn73, IBBtnStyles*)
Gui, Add, Button, x+20 yp w200 h40 hWndhBtn74, % "Info"
IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; normal
, [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; hover
, [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; pressed
, [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ]
ImageButton.Create(hBtn74, IBBtnStyles*)
; ---------------------------------------------------------------------------------------
Gui, Show,, Image Buttons
return
GuiClose:
GuiEscape:
ExitApp
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: [Class] ImageButton - 1.5.00.00 - 20201230
I like it jNizM
Re: [Class] ImageButton - 1.5.00.00 - 20201230
That’s awesome jNizM. Thanks for sharing.
Re: [Class] ImageButton - 1.5.00.00 - 20201230
What a mad lad, thank you for your example, hoping to see this with AHK 2 (unlikely but one can only hope lol)jNizM wrote: ↑09 Jul 2021, 07:59Example of Bootstrap like Buttons
Code: Select all
#NoEnv SetBatchLines, -1 ; Class ImageButton by just me ; https://www.autohotkey.com/boards/viewtopic.php?t=1103 #Include Class_ImageButton.ahk Gui, Margin, 20, 20 Gui, Font, s11 normal, Segoe UI ; --------------------------------------------------------------------------------------- Gui, Add, Button, xm ym w80 h24 hWndhBtn11, % "Critical" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ; normal , [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 1] ; hover , [0, 0x80E27C79, , , 0, , 0x80D43F3A, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ] ImageButton.Create(hBtn11, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn12, % "Warning" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ; normal , [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 1] ; hover , [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ] ImageButton.Create(hBtn12, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn13, % "Success" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ; normal , [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 1] ; hover , [0, 0x8091CF91, , , 0, , 0x805CB85C, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ] ImageButton.Create(hBtn13, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn14, % "Info" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ; normal , [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 1] ; hover , [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ] ImageButton.Create(hBtn14, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, x+20 yp w80 h24 hWndhBtn21, % "Critical" IBBtnStyles := [ [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 1] ; normal , [0, 0x80E27C79, , , 0, , 0x80D43F3A, 1] ; hover , [0, 0x80D43F3A, , , 0, , 0x80D43F3A, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 1] ] ImageButton.Create(hBtn21, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn22, % "Warning" IBBtnStyles := [ [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 1] ; normal , [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 1] ; hover , [0, 0x80F0AD4E, , , 0, , 0x80F0AD4E, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 1] ] ImageButton.Create(hBtn22, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn23, % "Success" IBBtnStyles := [ [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 1] ; normal , [0, 0x8091CF91, , , 0, , 0x805CB85C, 1] ; hover , [0, 0x805CB85C, , , 0, , 0x805CB85C, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 1] ] ImageButton.Create(hBtn23, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn24, % "Info" IBBtnStyles := [ [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 1] ; normal , [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 1] ; hover , [0, 0x8046B8DA, , , 0, , 0x8046B8DA, 1] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 1] ] ImageButton.Create(hBtn24, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, xm y+20 w80 h24 hWndhBtn31, % "Critical" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; normal , [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; hover , [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ] ImageButton.Create(hBtn31, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn32, % "Warning" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; normal , [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; hover , [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ] ImageButton.Create(hBtn32, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn33, % "Success" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; normal , [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; hover , [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ] ImageButton.Create(hBtn33, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn34, % "Info" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; normal , [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; hover , [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ] ImageButton.Create(hBtn34, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, x+20 yp w80 h24 hWndhBtn41, % "Critical" IBBtnStyles := [ [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; normal , [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; hover , [0, 0x80D43F3A, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 1] ] ImageButton.Create(hBtn41, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn42, % "Warning" IBBtnStyles := [ [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; normal , [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; hover , [0, 0x80F0AD4E, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 1] ] ImageButton.Create(hBtn42, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn43, % "Success" IBBtnStyles := [ [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; normal , [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; hover , [0, 0x805CB85C, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 1] ] ImageButton.Create(hBtn43, IBBtnStyles*) Gui, Add, Button, x+20 yp w80 h24 hWndhBtn44, % "Info" IBBtnStyles := [ [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; normal , [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; hover , [0, 0x8046B8DA, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 1] ] ImageButton.Create(hBtn44, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, xm y+20 w200 h40 hWndhBtn51, % "Critical" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ; normal , [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 2] ; hover , [0, 0x80E27C79, , , 0, , 0x80D43F3A, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ] ImageButton.Create(hBtn51, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn52, % "Warning" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ; normal , [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 2] ; hover , [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ] ImageButton.Create(hBtn52, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn53, % "Success" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ; normal , [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 2] ; hover , [0, 0x8091CF91, , , 0, , 0x805CB85C, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ] ImageButton.Create(hBtn53, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn54, % "Info" IBBtnStyles := [ [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ; normal , [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 2] ; hover , [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ] ImageButton.Create(hBtn54, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, xm y+20 w200 h40 hWndhBtn61, % "Critical" IBBtnStyles := [ [0, 0x80F0B9B8, , , 0, , 0x80D43F3A, 2] ; normal , [0, 0x80E27C79, , , 0, , 0x80D43F3A, 2] ; hover , [0, 0x80D43F3A, , , 0, , 0x80D43F3A, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80D43F3A, 2] ] ImageButton.Create(hBtn61, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn62, % "Warning" IBBtnStyles := [ [0, 0x80FCEFDC, , , 0, , 0x80F0AD4E, 2] ; normal , [0, 0x80F6CE95, , , 0, , 0x80F0AD4E, 2] ; hover , [0, 0x80F0AD4E, , , 0, , 0x80F0AD4E, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x80F0AD4E, 2] ] ImageButton.Create(hBtn62, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn63, % "Success" IBBtnStyles := [ [0, 0x80C6E6C6, , , 0, , 0x805CB85C, 2] ; normal , [0, 0x8091CF91, , , 0, , 0x805CB85C, 2] ; hover , [0, 0x805CB85C, , , 0, , 0x805CB85C, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x805CB85C, 2] ] ImageButton.Create(hBtn63, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn64, % "Info" IBBtnStyles := [ [0, 0x80C6E9F4, , , 0, , 0x8046B8DA, 2] ; normal , [0, 0x8086D0E7, , , 0, , 0x8046B8DA, 2] ; hover , [0, 0x8046B8DA, , , 0, , 0x8046B8DA, 2] ; pressed , [0, 0x80F0F0F0, , , 0, , 0x8046B8DA, 2] ] ImageButton.Create(hBtn64, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Add, Button, xm y+20 w200 h40 hWndhBtn71, % "Critical" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; normal , [0, 0x80F0B9B8, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; hover , [0, 0x80E27C79, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80D43F3A, 2] ] ImageButton.Create(hBtn71, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn72, % "Warning" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; normal , [0, 0x80FCEFDC, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; hover , [0, 0x80F6CE95, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x80F0AD4E, 2] ] ImageButton.Create(hBtn72, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn73, % "Success" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; normal , [0, 0x80C6E6C6, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; hover , [0, 0x8091CF91, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x805CB85C, 2] ] ImageButton.Create(hBtn73, IBBtnStyles*) Gui, Add, Button, x+20 yp w200 h40 hWndhBtn74, % "Info" IBBtnStyles := [ [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; normal , [0, 0x80C6E9F4, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; hover , [0, 0x8086D0E7, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ; pressed , [0, 0x80F0F0F0, , , 8, 0xFFF0F0F0, 0x8046B8DA, 2] ] ImageButton.Create(hBtn74, IBBtnStyles*) ; --------------------------------------------------------------------------------------- Gui, Show,, Image Buttons return GuiClose: GuiEscape: ExitApp