Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button
Posted: 09 Oct 2021, 06:05
Wow, that a wonderful tool, thank you He llbent
Let's help each other out
https://www.autohotkey.com/boards/
Hi dideautomatedideautomate wrote: ↑25 Oct 2021, 17:59To AutoHotKey Forum Staff:
I checked again and I see that the Editor's CODE is the same as the Button Class CODE.
For whatever reason, this was either changed by someone or the error was unintentional.
Please fix as this would probably solve many issues regarding other users wanting to use this
amazing tool,.
Thank you
Dwight
Code: Select all
;***************************************************************************************************
#Include <My Altered Gdip Lib> ; <----------- GDIP LIB
#Include <Gen 3 Buttons> ; <---------- HButton class
;***************************************************************************************************
#SingleInstance, Force
Gdip_Startup()
Theme1 := HBCustomButton()
GuiButtonType1.SetSessionDefaults( Theme1.All , Theme1.Default , Theme1.Hover , Theme1.Pressed )
MyFirstButton := New HButton( { Owner: 1 , X: 10 , Y: 10 , W: 100 , H: 35 , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" } )
Gui, 1:Show
return
GuiClose:
ExitApp
TestFunction(){
ToolTip, In the test function
SoundBeep, 500
}
HBCustomButton(){
local MyButtonDesign := {}
MyButtonDesign.All := {}
MyButtonDesign.Default := {}
MyButtonDesign.Hover := {}
MyButtonDesign.Pressed := {}
;********************************
;All
MyButtonDesign.All.W := 200 , MyButtonDesign.All.H := 65 , MyButtonDesign.All.Text := " Button " , MyButtonDesign.All.BackgroundColor := "0xFF22262A"
;********************************
;Default
MyButtonDesign.Default.W := 200 , MyButtonDesign.Default.H := 65 , MyButtonDesign.Default.Text := "Button" , MyButtonDesign.Default.Font := "Arial" , MyButtonDesign.Default.FontOptions := " Bold Center vCenter " , MyButtonDesign.Default.FontSize := "12" , MyButtonDesign.Default.H := "0x0002112F" , MyButtonDesign.Default.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Default.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Default.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Default.TextOffsetX := "0" , MyButtonDesign.Default.TextOffsetY := "0" , MyButtonDesign.Default.TextOffsetW := "0" , MyButtonDesign.Default.TextOffsetH := "0" , MyButtonDesign.Default.BackgroundColor := "0xFF22262A" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFF161B1F" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Default.ButtonMainColor1 := "0xFF272C32" , MyButtonDesign.Default.ButtonMainColor2 := "0xFF272C32" , MyButtonDesign.Default.ButtonAddGlossy := "1" , MyButtonDesign.Default.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
;********************************
;Hover
MyButtonDesign.Hover.W := 200 , MyButtonDesign.Hover.H := 65 , MyButtonDesign.Hover.Text := "Button" , MyButtonDesign.Hover.Font := "Arial" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "12" , MyButtonDesign.Hover.H := "0x0002112F" , MyButtonDesign.Hover.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Hover.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextOffsetX := "0" , MyButtonDesign.Hover.TextOffsetY := "0" , MyButtonDesign.Hover.TextOffsetW := "0" , MyButtonDesign.Hover.TextOffsetH := "0" , MyButtonDesign.Hover.BackgroundColor := "0xFF22262A" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0xFF161B1F" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFF122BE6" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFF0006EE" , MyButtonDesign.Hover.ButtonAddGlossy := "1" , MyButtonDesign.Hover.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
;********************************
;Pressed
MyButtonDesign.Pressed.W := 200 , MyButtonDesign.Pressed.H := 65 , MyButtonDesign.Pressed.Text := "Button" , MyButtonDesign.Pressed.Font := "Arial" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "12" , MyButtonDesign.Pressed.H := "0x0002112F" , MyButtonDesign.Pressed.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Pressed.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFF22262A" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFF62666a" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xFF151A20" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xFF151A20" , MyButtonDesign.Pressed.ButtonMainColor1 := "0xFF12161a" , MyButtonDesign.Pressed.ButtonMainColor2 := "0xFF33383E" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
;********************************
return MyButtonDesign
}
Code: Select all
;***************************************************************************************************
#Include <My Altered Gdip Lib> ; <----------- GDIP LIB
#Include <Gen 3 Buttons> ; <---------- HButton class
;***************************************************************************************************
#SingleInstance, Force
Gdip_Startup()
;***************************************************
Theme1 := HBCustomButton()
GuiButtonType1.SetSessionDefaults( Theme1.All , Theme1.Default , Theme1.Hover , Theme1.Pressed )
;***************************************************
Gui, 1:+AlwaysOnTop
Gui, 1:Font, s12 , Arial
Gui, 1:Margin, % m := 10 , 10
Gui, 1:Add, ListBox, xm ym w320 r10, Item 1||Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|
;***************************************************
Gui, 1:-DPIScale
Button1 := New HButton( { Owner: 1 , X: ( (A_ScreenDPI / 96 ) * m ) , Y: "+" ( (A_ScreenDPI / 96 ) * m ) , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Button2 := New HButton( { Owner: 1 , X: "+" ( (A_ScreenDPI / 96 ) * m ) , Y: "p" , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Button3 := New HButton( { Owner: 1 , X: "+" ( (A_ScreenDPI / 96 ) * m ) , Y: "p" , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Gui, 1:+DPIScale
;***************************************************
Gui, 1:Add, Checkbox, xm y+10 , Checkbox
Gui, 1:Add, Button, x+10 yp , Button
Gui, 1:Add, DDL, xm w320 r10, Item 1||Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|
;***************************************************
Gui, 1:-DPIScale
Button4 := New HButton( { Owner: 1 , X: ( (A_ScreenDPI / 96 ) * m ) , Y: "+" ( (A_ScreenDPI / 96 ) * m ) , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Button5 := New HButton( { Owner: 1 , X: "+" ( (A_ScreenDPI / 96 ) * m ) , Y: "p" , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Button6 := New HButton( { Owner: 1 , X: "+" ( (A_ScreenDPI / 96 ) * m ) , Y: "p" , W: ( (A_ScreenDPI / 96 ) * 100 ) , H: ( (A_ScreenDPI / 96 ) * 35 ) , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" , FontSize: ( 12 * ( A_ScreenDPI / 96 ) ) } )
Gui, 1:+DPIScale
;***************************************************
Gui, 1:Add, Checkbox, xm y+10 , Checkbox
Gui, 1:Add, Button, x+10 yp , Button
Gui, 1:Add, DDL, xm w320 r10, Item 1||Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|Item 1|
;***************************************************
Gui, 1:Show
return
GuiClose:
ExitApp
TestFunction(){
ToolTip, In the test function
SoundBeep, 500
}
HBCustomButton(){
local MyButtonDesign := {}
MyButtonDesign.All := {}
MyButtonDesign.Default := {}
MyButtonDesign.Hover := {}
MyButtonDesign.Pressed := {}
;********************************
;All
MyButtonDesign.All.W := 200 , MyButtonDesign.All.H := 65 , MyButtonDesign.All.Text := " Button " , MyButtonDesign.All.BackgroundColor := "0xFF22262A"
;********************************
;Default
MyButtonDesign.Default.W := 200 , MyButtonDesign.Default.H := 65 , MyButtonDesign.Default.Text := "Button" , MyButtonDesign.Default.Font := "Arial" , MyButtonDesign.Default.FontOptions := " Bold Center vCenter " , MyButtonDesign.Default.FontSize := "12" , MyButtonDesign.Default.H := "0x0002112F" , MyButtonDesign.Default.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Default.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Default.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Default.TextOffsetX := "0" , MyButtonDesign.Default.TextOffsetY := "0" , MyButtonDesign.Default.TextOffsetW := "0" , MyButtonDesign.Default.TextOffsetH := "0" , MyButtonDesign.Default.BackgroundColor := "0xFF22262A" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFF161B1F" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Default.ButtonMainColor1 := "0xFF272C32" , MyButtonDesign.Default.ButtonMainColor2 := "0xFF272C32" , MyButtonDesign.Default.ButtonAddGlossy := "1" , MyButtonDesign.Default.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
;********************************
;Hover
MyButtonDesign.Hover.W := 200 , MyButtonDesign.Hover.H := 65 , MyButtonDesign.Hover.Text := "Button" , MyButtonDesign.Hover.Font := "Arial" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "12" , MyButtonDesign.Hover.H := "0x0002112F" , MyButtonDesign.Hover.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Hover.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextOffsetX := "0" , MyButtonDesign.Hover.TextOffsetY := "0" , MyButtonDesign.Hover.TextOffsetW := "0" , MyButtonDesign.Hover.TextOffsetH := "0" , MyButtonDesign.Hover.BackgroundColor := "0xFF22262A" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0xFF161B1F" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFF122BE6" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFF0006EE" , MyButtonDesign.Hover.ButtonAddGlossy := "1" , MyButtonDesign.Hover.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
;********************************
;Pressed
MyButtonDesign.Pressed.W := 200 , MyButtonDesign.Pressed.H := 65 , MyButtonDesign.Pressed.Text := "Button" , MyButtonDesign.Pressed.Font := "Arial" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "12" , MyButtonDesign.Pressed.H := "0x0002112F" , MyButtonDesign.Pressed.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Pressed.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFF22262A" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFF62666a" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xFF151A20" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xFF151A20" , MyButtonDesign.Pressed.ButtonMainColor1 := "0xFF12161a" , MyButtonDesign.Pressed.ButtonMainColor2 := "0xFF33383E" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
;********************************
return MyButtonDesign
}
PENchanter wrote: ↑24 Dec 2021, 20:09WHAAAT?! Why am I being designated as "Old" and recommended for "Delete"[ion]?!?! *shudders* Why me?!?!?!
Code: Select all
_CreateControl( Input ){
local hwnd
Gui , % Input.Owner ":Add" , Pic , % "x" Input.X " y" Input.Y " w" Input.W " h" Input.H " v" Input.V " hwndhwnd 0xE"
; ^-----------^ *Add this in
return hwnd
}
Code: Select all
MyFirstButton := New HButton( { Owner: 1 , X: 10 , Y: 10 , W: 100 , H: 35 , V: "TestButton1" , Text: "Reload" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" } )
; ^----------------^ *Add this in
Code: Select all
Gui, 1:Add , Text , hwndTextHwnd
GuiControl, 1: , % TextHwnd , Hello ;<---- Using the handle
Gui, 1:Add, Text , vTextVar
GuiControl, 1: , TextVar , Hello ;<---- Using the variable
Code: Select all
MouseGetPos,,,, ctrl , 2 ;<---- get the handle ( hwnd ) of the control under the cursor.
@Maestr0:Maestr0 wrote: ↑29 May 2023, 13:29I couldn't find it in the manual, but I did a Bing.com chat (so AI)...
I've not tested it, though.
[...]Yes, you can make a button appear pressed in the GUI without pressing it. You can use the `GuiControl` command with the `+E` option to enable or disable a control. For example, if you have a button with the name `Button1`, you can use the following code to make it appear pressed:
[...]Code: Select all
GuiControl,, Button1, +E
But this quote is actually about GUI styles, not styles of specific GUI elements.https://www.autohotkey.com/docs/v1/lib/Gui.htm#Options wrote:(Unnamed ExStyle): Specify a plus or minus sign followed immediately by the letter E and a decimal or hexadecimal extended style number. For example, +E0x40000 would add the WS_EX_APPWINDOW style, which provides a taskbar button for a window that would otherwise lack one. For other extended styles not documented here (since they are rarely used), see Extended Window Styles | Microsoft Docs for a complete list.