[ Class + ( Editor Tool ) ] Custom Gui Image Button

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button

Post by Maestr0 » 30 May 2023, 00:42

gregster wrote:
29 May 2023, 16:05
Thanks for your feedback. I'll refrain trying to help without researching the exact question and testing the result.

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button

Post by Hellbent » 31 May 2023, 04:17

rx65m wrote:
27 May 2023, 11:53
I wonder how can we do to make the buttons created by this amazing piece of software to remain pressed until we click on them again.
Probably it is there, but I haven't found nothing so far.

These buttons don't have a lot of features built into them.

I think that the simplest way to get what you are looking for is to add a picture control with the pressed bitmap drawn on it put it in the same position and when you click on the button it hides the button and shows the picture and then when you click it again it reverses actions.

Here is an example.

.
custom button pressed.gif
custom button pressed.gif (120.82 KiB) Viewed 569 times
.

Code: Select all

;***************************************************************************************************
#Include <My Altered Gdip Lib> ; <----------- GDIP LIB
#Include <Gen 3 Buttons> ; <---------- HButton class
;***************************************************************************************************
#SingleInstance, Force
Gdip_Startup()

Gui, +AlwaysOnTop 
Gui, Margin, 30 , 30
Gui, Color, 22262a

;create a picture control and position it and size it to be the same as your button and have it call the same function for the toggling function. 
Gui,1:Add, Picture, x30 y30 w150 h45 hwndPicHwnd 0xE gTestFunction 

;Get the custom design
ButtonDesign := HBCustomButton()

;create a new button 
global MyFirstButton := New HButton( { Owner: 1 , X: 30 , Y: 30 , W: 150 , H: 45 , Text: "OK" , Label: "TestFunction" } , ButtonDesign.All , ButtonDesign.Default , ButtonDesign.Hover , ButtonDesign.Pressed )

Gui, 1:Show

return
GuiClose: 
*ESC::ExitApp

;*********************************************************************

TestFunction:
	if( tog := !tog ){ ;switch between the button and the picture 
		
		GuiControl, 1:Show , % PicHwnd 
		GuiControl, 1:Hide , % MyFirstButton 
		SetImage( PicHwnd , HButton.Button[ MyFirstButton ].Bitmaps.Pressed.hBitmap )
		
	}else{ ;switch back
		
		GuiControl, 1:Hide , % PicHwnd 
		GuiControl, 1:Show , % MyFirstButton 
		SetImage( MyFirstButton , HButton.Button[ MyFirstButton ].Bitmaps.Hover.hBitmap )

	}

	ToolTip, In the test function , 200
	;SoundBeep, 500
	
	return

;*********************************************************************

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" , MyButtonDesign.All.ButtonAddGlossy := "0"
	;********************************
	;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 := "0" , 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 := "0xFF59B5B7" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFF2E3C44" , MyButtonDesign.Hover.ButtonAddGlossy := "0" , 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 := "0xFF007DFF" , MyButtonDesign.Pressed.ButtonMainColor2 := "0xFF020E3B" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
	;********************************
	
	return MyButtonDesign
}

There are ways to make it pretty much flicker free but it requires a bit more effort.

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button

Post by Hellbent » 23 Aug 2023, 15:49

New Theme:


.
Button theme.gif
Button theme.gif (684.1 KiB) Viewed 329 times
.

.
20230823165036.png
20230823165036.png (32.14 KiB) Viewed 328 times
.


BG Color: 212B37

Code: Select all


NewTheme(){
	local MyButtonDesign := {}
	MyButtonDesign.All := {}
	MyButtonDesign.Default := {}
	MyButtonDesign.Hover := {}
	MyButtonDesign.Pressed := {}
	;********************************
	;All
	MyButtonDesign.All.W := 120 , MyButtonDesign.All.H := 35 , MyButtonDesign.All.Text := "Show / Hide" , MyButtonDesign.All.Font := "Cambria" , MyButtonDesign.All.FontSize := "14" , MyButtonDesign.All.BackgroundColor := "0xFF212B37" , MyButtonDesign.All.ButtonAddGlossy := "0"
	;********************************
	;Default
	MyButtonDesign.Default.W := 120 , MyButtonDesign.Default.H := 35 , MyButtonDesign.Default.Text := "Show / Hide" , MyButtonDesign.Default.Font := "Cambria" , MyButtonDesign.Default.FontOptions := " Center vCenter Bold" , MyButtonDesign.Default.FontSize := "14" , MyButtonDesign.Default.H := "0xff02112F" , MyButtonDesign.Default.TextBottomColor2 := "0xff02112F" , 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 := "0xFF212B37" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFF3B4D63" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF5C789A" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Default.ButtonMainColor1 := "0xFF212B37" , MyButtonDesign.Default.ButtonMainColor2 := "0xFF212B37" , MyButtonDesign.Default.ButtonAddGlossy := "0" , MyButtonDesign.Default.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
	;********************************
	;Hover
	MyButtonDesign.Hover.W := 120 , MyButtonDesign.Hover.H := 35 , MyButtonDesign.Hover.Text := "Show / Hide" , MyButtonDesign.Hover.Font := "Cambria" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "14" , MyButtonDesign.Hover.H := "0xff02112F" , MyButtonDesign.Hover.TextBottomColor2 := "0xff02112F" , 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 := "0xFF212B37" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0xFF5E7B9D" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFF5A7596" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFF2E3C4C" , MyButtonDesign.Hover.ButtonAddGlossy := "0" , MyButtonDesign.Hover.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
	;********************************
	;Pressed
	MyButtonDesign.Pressed.W := 120 , MyButtonDesign.Pressed.H := 35 , MyButtonDesign.Pressed.Text := "Show / Hide" , MyButtonDesign.Pressed.Font := "Cambria" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "14" , MyButtonDesign.Pressed.H := "0xffB0BFD0" , MyButtonDesign.Pressed.TextBottomColor2 := "0xffB0BFD0" , MyButtonDesign.Pressed.TextTopColor1 := "0xFF000000" , MyButtonDesign.Pressed.TextTopColor2 := "0xFF000000" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFF212B37" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFF" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFF" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xffA3B4C8" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xff80FFFF" , MyButtonDesign.Pressed.ButtonMainColor1 := "0x99283442" , MyButtonDesign.Pressed.ButtonMainColor2 := "0x99597494" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
	;********************************
	
	return MyButtonDesign
}


peter_ahk
Posts: 86
Joined: 13 Feb 2024, 14:49

Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button

Post by peter_ahk » 18 Feb 2024, 05:41

hi there

years ago you helped me with the pButton class you created. and also with some sessions using your button creating tool, live has been a rollercoaster and i stopped coding coz of it years ago but a recent drive crash is forcing me to need to rewrite a few programs and i forgot how to do a few things myself and cant figure it out so i wonder can i pay you to modify it to load the 5 colors i set in a ini file so it uses those colors to draw the buttons. Also i like text on the buttons to be loaded from that same ini file this is the last thing i need to know to remake things the way i had it its worth some money to me but i am not a rich guy :) so within reason

peter_ahk
Posts: 86
Joined: 13 Feb 2024, 14:49

Re: [ Class + ( Editor Tool ) ] Custom Gui Image Button

Post by peter_ahk » 23 Feb 2024, 07:42

:) it appears i can not reply to pm's coz i am a noob :) i did send ya a mail earlyer today

Post Reply

Return to “Scripts and Functions (v1)”