Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post your working scripts, libraries and tools for AHK v1.1 and older
joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 03:05

New Bitmap Image.jpg
New Bitmap Image.jpg (88.74 KiB) Viewed 5624 times
@Hellbent

amazing gui and controls as always! i got your radio button to work and now im looking for the sunkin radio buttons you made. heres a screenshot so far. many thanks for the help!!
joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 16:42

@Hellbent

your new (on) switch graphic you just posted

Code: Select all

HB_BITMAP_MAKER( ScaleFactor := 1 ){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 19 * ScaleFactor , 19 * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF3A3B3D" ) , Gdip_FillRectangle( G , Brush , -1 * ScaleFactor , -1 * ScaleFactor , 21 * ScaleFactor , 21 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF484A4B" ) , Gdip_FillEllipse( G , Brush , 1 * ScaleFactor , 1 * ScaleFactor , 17 * ScaleFactor , 17 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF1A1C1F" ) , Gdip_FillEllipse( G , Brush , 1 * ScaleFactor , 0 * ScaleFactor , 17 * ScaleFactor , 17 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF29292F" ) , Gdip_FillEllipse( G , Brush , 2 * ScaleFactor , 1 * ScaleFactor , 15 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 5 * ScaleFactor , 1 * ScaleFactor , 10 * ScaleFactor , 14 * ScaleFactor , "0xFF2E2F31" , "0xFF333337" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 3 * ScaleFactor , 2 * ScaleFactor , 13 * ScaleFactor , 13 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF4D5055" ) , Gdip_FillEllipse( G , Brush , 7 * ScaleFactor , 7 * ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF222325" ) , Gdip_FillEllipse( G , Brush , 7 * ScaleFactor , 6 * ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap
}
my current graphic for on

Code: Select all

Create_On_Bitmap(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap:=Gdip_CreateBitmap( This.W , This.H ),G := Gdip_GraphicsFromImage( pBitmap ),Gdip_SetSmoothingMode( G , 4 )
	Brush := Gdip_BrushCreateSolid( This.Background_Color ),Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+3 , This.H+3 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF555555" ),Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , 66 , 26 , 5 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 3 , 64 , 24 , "0xFF151515" , "0xFF222222" , 1 , 1 ),Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , 66 , 25 , 5 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 4 , 67 , 28 , "0x88000000" , "0x88222222" , 3 , 3 ),Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , 66 , 25 , 5 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 3 , 64 , 24 , "0xFF252525" , "0xFF222222" , 1 , 1 ),Gdip_FillRoundedRectangle( G , Brush , 4 , 5 , 62 , 19 , 7 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 4 , 67 , 28 , "0x88000000" , "0x88222222" , 3 , 3 ),Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , 66 , 25 , 5 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 4 , 67 , 28 , "0x44000000" , "0x44222222" , 3 , 3 ),Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , 66 , 25 , 5 ),Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF000000" , 1 ),Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 66 , 25 , 5 ),Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 3 , 2 , 30 , 25 , "0xFF222222" , "0xFF151515" , 1 , 1 ),Gdip_FillRoundedRectangle( G , Brush , 33 , 2 , 35 , 25 , 5 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 4 , 4 , 28 , 24 , "0xaa373737" , "0xaa222222" , 1 , 1 ),Gdip_FillRoundedRectangle( G , Brush , 35 , 3 , 32 , 23 , 5 ),Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF000000" , 1 ),Gdip_DrawRoundedRectangle( G , Pen , 34 , 2 , 34 , 25 , 5 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x665F5F5F" , 2 ),Gdip_DrawLine( G , Pen , 42 , 11 , 63 , 11 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xff202020" , 1 ),Gdip_DrawLine( G , Pen , 42 , 12 , 63 , 12 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x665F5F5F" , 2 ),Gdip_DrawLine( G , Pen , 42 , 15 , 63 , 15 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xff202020" , 1 ),Gdip_DrawLine( G , Pen , 42 , 16 , 63 , 16 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x665F5F5F" , 2 ),Gdip_DrawLine( G , Pen , 42 , 19 , 63 , 19 ),Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xff1a1a1a" , 1 ),Gdip_DrawLine( G , Pen , 42 , 21 , 63 , 21 ),Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF008000" ),Gdip_TextToGraphics( G , "ON" , Config[11] " Center vCenter Bold c" Brush " x-8 y2" , Config[9] , 50 , 30 ),Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( This.Font_Color ),Gdip_TextToGraphics( G , This.Text , Config[11] " vCenter c" Brush " x75 y" 2+This.Y_Offset , Config[9] , This.W-75 , This.H ),Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G ),This.Switch_On_Bitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmap),Gdip_DisposeImage(pBitmap)
}


i thought i could just copy and replace this section, but not seeming to work. i figured the rest of the logic would stay the same. should i be able to just replace this section for the (on) and the other section for the (off)?
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 17:30

Hi @joekingcool.

First, thanks for the coffees!

Second, ( not related to the first lol ) I wrote a new updated version of the Radio class last night and did a little simple design that I think will work well with your gui.

Here is a demo of using the class, as you can see the radios are scalable. You can either use the value for A_ScreenDPI or if you are using 100% normally, then you can pick whatever scale you want. Be sure to note how I turn off the guis dpi scaling before adding the controls and then back on afterwards. This is done because it needs to use the scaling you supply it and not the be based on your computer settings. You also shouldn't try to combine the normal scaling and custom scaling without testing. ( i.e. If computer scaling is on - use it and only it )

Code: Select all

#Include <My Altered Gdip Lib>
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd
Gui, Color, % Background := "333333"
;######################################################################################################################################################################
scale := 1
Y_Offset := 1
X_Offset := 5
Gui, -DPIScale
Admin := New GlowRadio_1( { Scalefactor: scale , State: 1 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
User := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Other := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 1.5
Y_Offset := 1
X_Offset := 2
OtherGroup := []
OtherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group2" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 2
Y_Offset := 1
X_Offset := 2
AnotherGroup := []
AnotherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group3" , Scalefactor: scale , State: 1 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "Waldo" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 3
Y_Offset := 1
X_Offset := 1
OneLastGroup := []
OneLastGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group4" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Gui, +DPIScale
;######################################################################################################################################################################
Gui, Show,,Custom Radio Controls

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*********************************************************************************************************************************
;How to get the output from the radios
RALT::
	ToolTip, % "Selected item from Group 1: " Admin.GetSelected()
	
			. "`nThe text on the selected item is: " GlowRadio_1.Groups[ "Group1" ].Members[ Admin.GetSelected() ].Text
			
			. "`n`n`nSelected item from group 2: " OtherGroup[ 1 ].GetSelected()
			
			. "`n`nThe State of ""OneLastGroup[ 2 ]"" is: " OneLastGroup[ 2 ].State " [ " OneLastGroup[ 2 ].GetState() " ] "
	return
;*********************************************************************************************************************************

;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1	{
	;Written By: Hellbent
	;Date: Aprial 6th , 2022
	;Creates new instances of gui Radio controls and groups
	;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
	;Get Selected Item From Group Example: MyRadio..GetSelected()  ;(Returns the position of the selected radio in it's group )
	;Get The State Of A Radio Example: MyRadio.State    ;Or: MyRadio.GetState() 
	static init := GlowRadio_1._SetDefaults()
	_SetDefaults(){
		This.W := 11 
		This.H := 11
		This.Groups := {}
		This.Index := 0
		This.Settings := {}
		This.Settings.X := 10
		This.Settings.Y := 10
		This.Settings.W := 120
		This.Settings.H := 20
		This.Settings.Text := ""
		This.Settings.ActiveColor := "0xFF67D5D6"
		This.Settings.ButtonRestColor := "0xFF004444"
		This.Settings.RestColor := "0xFF009999"
		This.Settings.State := 0
		This.Settings.Font := "Arial"
		This.Settings.FontSize := 14
		This.Settings.FontOptions := " vCenter Left "
		This.Settings.BackgroundColor := "0xFF22262a"
		This.Settings.GroupName := "Group1"
		This.Settings.Owner := "1"
		This.Settings.GroupIndex := 1
		This.Settings.GroupSelected := 0
		This.Settings.ScaleFactor := 1
		This.Settings.Y_Offset := 5
		This.Settings.X_Offset := 1
		
	}
	__New( obj := "" ){
		
		This._CreateRadioObject( obj )
		This._CreateControl()
		This.Draw()
	}
	_CreateRadioObject( obj := "" ){
		local k , v 
		for k , v in GlowRadio_1.Settings
			This[ k ] := v 
		if( IsObject( obj ) ){
			for k , v in obj 
				if( GlowRadio_1.Settings.HasKey( k ) )
					This[ k ] := v 
			if( obj.HasKey( "GroupName" ) )
				GlowRadio_1.Settings.GroupName := obj.GroupName
		}
	}
	_CreateControl(){
		local hwnd , bd
		Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
		This.Hwnd := hwnd
		++GlowRadio_1.Index
		If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
			If( This.State ){
				GlowRadio_1.Groups[ This.GroupName ] := {}
				This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
				This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 1
				GlowRadio_1.Groups[ This.GroupName ].Members := []
				GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
			}else{
				GlowRadio_1.Groups[ This.GroupName ] := {}
				This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
				This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0
				GlowRadio_1.Groups[ This.GroupName ].Members := []
				GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
			}
		}else{
			if( This.State ){
				This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
				This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Index
				GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
			}else{
				This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
				This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
				GlowRadio_1.Groups[ This.GroupName ].Members[ GlowRadio_1.Groups[ This.GroupName ].Index ] := This
			}
		}
		bd := This._SwitchStates.Bind( This )
		GuiControl, % This.Owner ":+G" , % Hwnd , % bd
		GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
		for k , v in GlowRadio_1.Groups[ This.GroupName ].Members
			GlowRadio_1.Groups[ This.GroupName ].Members[ k ].GroupSelected := This.GroupSelected
			if( A_Index = This.GroupSelected )
				GlowRadio_1.Groups[ This.GroupName ].Members[ k ].State := 1
		Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	
			GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
		GuiControl, % This.Owner ":Focus", % This.Hwnd	
	}
	_SwitchStates(){
		local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
		cc.Selected := This.Index
		Loop, % cc.Members.Length()	{
			cc.Members[ A_Index ].GroupSelected := cc.Selected
			cc.Members[ A_Index ].State := 0
		}
		This.State := 1
		Loop, % cc.Members.Length()
			cc.Members[ A_Index ].Draw()
		GuiControl, % This.Owner ":Focus", % This.Hwnd
	}
	GetState(){
		return 	This.State
	}
	GetSelected(){
		return This.GroupSelected
	}
	Draw(){
		;Bitmap Created Using: HB Bitmap Maker
		local ly := 0
		ScaleFactor := This.ScaleFactor
		pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;Outer ring
		Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
		;inner square
		Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;bottom layer of text
		if( This.State )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		else
			Brush := Gdip_BrushCreateSolid(  "0x000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" Floor( ( GlowRadio_1.W + 5 + 2 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		;top layer of text
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		SetImage( This.Hwnd , hBitmap )
		Gdip_DisposeImage( pBitmap )
		DeleteObject( hBitmap )
	}
}


Animation.gif
Animation.gif (84.95 KiB) Viewed 5572 times
*NOTE* This class is super "Lite". There is no cleanup function or a way to reset groups. It is intended as it is to create a group and the gui with it once between reloads. You can have as many groups as you want. You just can't destroy the gui and reuse.

I'll take a look at your new code when I get the chance, if you have any questions about the new class just ask ( Perhaps in the Help section ).
joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 18:07

@hellbent

Well over due for a coffee:) your doing allot of great work on here!

love the new glow radio buttons, will work on them asap. :)
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 18:43

joekingcool wrote:
06 Apr 2022, 18:07
love the new glow radio buttons, will work on them asap. :)
I made a few changes to the class to make it a bit more optimized.

Code: Select all

#Include <My Altered Gdip Lib>
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd
Gui, Color, % Background := "333333"
;######################################################################################################################################################################
scale := 1
Y_Offset := 1
X_Offset := 5
Gui, -DPIScale
Admin := New GlowRadio_1( { Scalefactor: scale , State: 1 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
User := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Other := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 1.5
Y_Offset := 1
X_Offset := 2
OtherGroup := []
OtherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group2" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 2
Y_Offset := 1
X_Offset := 2
AnotherGroup := []
AnotherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group3" , Scalefactor: scale , State: 1 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "Waldo" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 3
Y_Offset := 1
X_Offset := 1
OneLastGroup := []
OneLastGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group4" , Scalefactor: scale , State: 0 , X: 130 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 1 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Gui, +DPIScale
;######################################################################################################################################################################
Gui, Add, Edit, xm y+30 w300 r1
Gui, Show,,Custom Radio Controls

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*********************************************************************************************************************************
;How to get the output from the radios
RALT::
	ToolTip, % "Selected item from Group 1: " Admin.GetSelected()
	
			. "`nThe text on the selected item is: " GlowRadio_1.Groups[ "Group1" ].Members[ Admin.GetSelected() ].Text
			
			. "`n`n`nSelected item from group 2: " OtherGroup[ 1 ].GetSelected()
			
			. "`n`nThe State of ""OneLastGroup[ 2 ]"" is: " OneLastGroup[ 2 ].State " [ " OneLastGroup[ 2 ].GetState() " ] "
	return
;*********************************************************************************************************************************

;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1	{
	;Written By: Hellbent
	;Date: Aprial 6th , 2022
	;Creates new instances of gui Radio controls and groups
	;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
	;Get Selected Item From Group Example: MyRadio..GetSelected()  ;(Returns the position of the selected radio in it's group )
	;Get The State Of A Radio Example: MyRadio.State    ;Or: MyRadio.GetState() 
	static init := GlowRadio_1._SetDefaults()
	_SetDefaults(){
		This.W := 11 
		This.H := 11
		This.Groups := {}
		This.Index := 0
		This.Settings := {}
		This.Settings.X := 10
		This.Settings.Y := 10
		This.Settings.W := 120
		This.Settings.H := 20
		This.Settings.Text := ""
		This.Settings.ActiveColor := "0xFF67D5D6"
		This.Settings.ButtonRestColor := "0xFF004444"
		This.Settings.RestColor := "0xFF009999"
		This.Settings.State := 0
		This.Settings.Font := "Arial"
		This.Settings.FontSize := 14
		This.Settings.FontOptions := " vCenter Left "
		This.Settings.BackgroundColor := "0xFF22262a"
		This.Settings.GroupName := "Group1"
		This.Settings.Owner := "1"
		This.Settings.GroupIndex := 1
		This.Settings.GroupSelected := 0
		This.Settings.ScaleFactor := 1
		This.Settings.Y_Offset := 5
		This.Settings.X_Offset := 1
	}
	__New( obj := "" ){
		
		This._CreateRadioObject( obj )
		This._CreateControl()
		if( This.State ){
			Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	{
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].State := 0
			}
			This.State := 1
		}
		Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	
			GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
	}
	_CreateRadioObject( obj := "" ){
		local k , v 
		for k , v in GlowRadio_1.Settings
			This[ k ] := v 
		if( IsObject( obj ) ){
			for k , v in obj 
				if( GlowRadio_1.Settings.HasKey( k ) )
					This[ k ] := v 
			if( obj.HasKey( "GroupName" ) )
				GlowRadio_1.Settings.GroupName := obj.GroupName
		}
	}
	_CreateControl(){
		local hwnd , bd
		Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
		This.Hwnd := hwnd
		++GlowRadio_1.Index
		If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
			GlowRadio_1.Groups[ This.GroupName ] := {}
			This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
			GlowRadio_1.Groups[ This.GroupName ].Members := []
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0 )
		}else{
			This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Selected )
		}
		GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
		bd := This._SwitchStates.Bind( This )
		GuiControl, % This.Owner ":+G" , % Hwnd , % bd
		GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
		GuiControl, % This.Owner ":Focus", % This.Hwnd
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.GroupSelected
	}
	_SwitchStates(){
		local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
		if( This.Index = GlowRadio_1.Groups[ This.GroupName ].LastSelected )
			return
		cc.Selected := This.Index
		Loop, % cc.Members.Length()	{
			cc.Members[ A_Index ].GroupSelected := cc.Selected
			cc.Members[ A_Index ].State := 0
		}
		This.State := 1
		cc.Members[ GlowRadio_1.Groups[ This.GroupName ].LastSelected ].Draw()
		This.Draw()
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.Index
		GuiControl, % This.Owner ":Focus", % This.Hwnd
	}
	GetState(){
		return 	This.State
	}
	GetSelected(){
		return This.GroupSelected
	}
	Draw(){
		;Bitmap Created Using: HB Bitmap Maker
		local ly := 0
		ScaleFactor := This.ScaleFactor
		pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;Outer ring
		Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
		;inner square
		Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;bottom layer of text
		if( This.State )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		else
			Brush := Gdip_BrushCreateSolid(  "0x000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" Floor( ( GlowRadio_1.W + 5 + 2 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		;top layer of text
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		SetImage( This.Hwnd , hBitmap )
		Gdip_DisposeImage( pBitmap )
		DeleteObject( hBitmap )
	}
}

joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 20:01

@Hellbent

thats pure scalable, love it. i posted in the help section, im not sure if it pinged you or not though.

i put in the glow radio button in my script although the text is a little blurry compared to the buttons, so i might go back to the flat round you made.
New Bitmap Image.jpg
New Bitmap Image.jpg (14.71 KiB) Viewed 5525 times
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 21:21

joekingcool wrote:
06 Apr 2022, 20:01
i put in the glow radio button in my script although the text is a little blurry compared to the buttons
I think that you may have a copy of the script from before I fixed a problem with the background.

to fix it you just need to add "0xFF" to the background color where they are getting added.
The error was because of this:

Code: Select all

Gui, Color, % Background := "333333"
I just forgot to add the "0xFF" with it for:

Code: Select all

... , BackgroundColor: "0xFF" Background ,...
BTW, you can very easily change the colors it uses for each and every radio. I might come up with a sample palette later.
Animation.gif
Animation.gif (111.7 KiB) Viewed 5522 times

Code: Select all

#Include <My Altered Gdip Lib>
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd
Gui, Color, % Background := "333333"
;######################################################################################################################################################################
scale := 1
Y_Offset := 1
X_Offset := 5
Gui, -DPIScale
Admin := New GlowRadio_1( { ButtonRestColor: "0xFF116600" , RestColor: "0xFF339922" , ActiveColor: "0xFF99ef77" , Scalefactor: scale , State: 1 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
User := New GlowRadio_1( { ButtonRestColor: "0xFF116600" , RestColor: "0xFF339922" , ActiveColor: "0xFF99ef77" , Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Other := New GlowRadio_1( { ButtonRestColor: "0xFF116600" , RestColor: "0xFF339922" , ActiveColor: "0xFF99ef77" , Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 1.5
Y_Offset := 1
X_Offset := 2
OtherGroup := []
OtherGroup[ 1 ] := New GlowRadio_1( { ButtonRestColor: "0xFF52565a" , RestColor: "0xFF92969a" , ActiveColor: "0xFFd2d6da" , GroupName: "Group2" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 2 ] := New GlowRadio_1( { ButtonRestColor: "0xFF52565a" , RestColor: "0xFF92969a" , ActiveColor: "0xFFd2d6da" , Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 3 ] := New GlowRadio_1( { ButtonRestColor: "0xFF52565a" , RestColor: "0xFF92969a" , ActiveColor: "0xFFd2d6da" , Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 2
Y_Offset := 1
X_Offset := 2
AnotherGroup := []
AnotherGroup[ 1 ] := New GlowRadio_1( { ButtonRestColor: "0xFF660000" , RestColor: "0xFF992222" , ActiveColor: "0xFFff4444" , GroupName: "Group3" , Scalefactor: scale , State: 1 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 2 ] := New GlowRadio_1( { ButtonRestColor: "0xFF660000" , RestColor: "0xFF992222" , ActiveColor: "0xFFff4444" , Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "Waldo" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 3 ] := New GlowRadio_1( { ButtonRestColor: "0xFF660000" , RestColor: "0xFF992222" , ActiveColor: "0xFFff4444" , Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 3
Y_Offset := 1
X_Offset := 1
OneLastGroup := []
OneLastGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group4" , Scalefactor: scale , State: 0 , X: 130 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 1 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Gui, +DPIScale
;######################################################################################################################################################################
Gui, Add, Edit, xm y+30 w300 r1
Gui, Show,,Custom Radio Controls

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*********************************************************************************************************************************
;How to get the output from the radios
RALT::
	ToolTip, % "Selected item from Group 1: " Admin.GetSelected()
	
			. "`nThe text on the selected item is: " GlowRadio_1.Groups[ "Group1" ].Members[ Admin.GetSelected() ].Text
			
			. "`n`n`nSelected item from group 2: " OtherGroup[ 1 ].GetSelected()
			
			. "`n`nThe State of ""OneLastGroup[ 2 ]"" is: " OneLastGroup[ 2 ].State " [ " OneLastGroup[ 2 ].GetState() " ] "
	return
;*********************************************************************************************************************************

;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1	{
	;Written By: Hellbent
	;Date: Aprial 6th , 2022
	;Creates new instances of gui Radio controls and groups
	;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
	;Get Selected Item From Group Example: MyRadio..GetSelected()  ;(Returns the position of the selected radio in it's group )
	;Get The State Of A Radio Example: MyRadio.State    ;Or: MyRadio.GetState() 
	static init := GlowRadio_1._SetDefaults()
	_SetDefaults(){
		This.W := 11 
		This.H := 11
		This.Groups := {}
		This.Index := 0
		This.Settings := {}
		This.Settings.X := 10
		This.Settings.Y := 10
		This.Settings.W := 120
		This.Settings.H := 20
		This.Settings.Text := ""
		This.Settings.ActiveColor := "0xFF67D5D6"
		This.Settings.ButtonRestColor := "0xFF004444"
		This.Settings.RestColor := "0xFF009999"
		This.Settings.State := 0
		This.Settings.Font := "Arial"
		This.Settings.FontSize := 14
		This.Settings.FontOptions := " vCenter Left "
		This.Settings.BackgroundColor := "0xFF22262a"
		This.Settings.GroupName := "Group1"
		This.Settings.Owner := "1"
		This.Settings.GroupIndex := 1
		This.Settings.GroupSelected := 0
		This.Settings.ScaleFactor := 1
		This.Settings.Y_Offset := 5
		This.Settings.X_Offset := 1
	}
	__New( obj := "" ){
		
		This._CreateRadioObject( obj )
		This._CreateControl()
		if( This.State ){
			Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	{
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].State := 0
			}
			This.State := 1
		}
		Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	
			GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
	}
	_CreateRadioObject( obj := "" ){
		local k , v 
		for k , v in GlowRadio_1.Settings
			This[ k ] := v 
		if( IsObject( obj ) ){
			for k , v in obj 
				if( GlowRadio_1.Settings.HasKey( k ) )
					This[ k ] := v 
			if( obj.HasKey( "GroupName" ) )
				GlowRadio_1.Settings.GroupName := obj.GroupName
		}
	}
	_CreateControl(){
		local hwnd , bd
		Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
		This.Hwnd := hwnd
		++GlowRadio_1.Index
		If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
			GlowRadio_1.Groups[ This.GroupName ] := {}
			This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
			GlowRadio_1.Groups[ This.GroupName ].Members := []
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0 )
		}else{
			This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Selected )
		}
		GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
		bd := This._SwitchStates.Bind( This )
		GuiControl, % This.Owner ":+G" , % Hwnd , % bd
		GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
		GuiControl, % This.Owner ":Focus", % This.Hwnd
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.GroupSelected
	}
	_SwitchStates(){
		local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
		if( This.Index = GlowRadio_1.Groups[ This.GroupName ].LastSelected )
			return
		cc.Selected := This.Index
		Loop, % cc.Members.Length()	{
			cc.Members[ A_Index ].GroupSelected := cc.Selected
			cc.Members[ A_Index ].State := 0
		}
		This.State := 1
		cc.Members[ GlowRadio_1.Groups[ This.GroupName ].LastSelected ].Draw()
		This.Draw()
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.Index
		GuiControl, % This.Owner ":Focus", % This.Hwnd
	}
	GetState(){
		return 	This.State
	}
	GetSelected(){
		return This.GroupSelected
	}
	Draw(){
		;Bitmap Created Using: HB Bitmap Maker
		local ly := 0
		ScaleFactor := This.ScaleFactor
		pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;Outer ring
		Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
		;inner square
		Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;bottom layer of text
		if( This.State )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		else
			Brush := Gdip_BrushCreateSolid(  "0x000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" Floor( ( GlowRadio_1.W + 5 + 2 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		;top layer of text
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		SetImage( This.Hwnd , hBitmap )
		Gdip_DisposeImage( pBitmap )
		DeleteObject( hBitmap )
	}
}

joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 21:47

New Bitmap Image.jpg
New Bitmap Image.jpg (9.03 KiB) Viewed 5517 times
that's funny i just finish tweaking the round one similar.

another issue i found was the x/y starting cord changes when you change the scaling. makes it a little difficult to match up with other buttons in the script.

the screenshots im doing aren't doing any justice. but on my screen some controls text is blurry and others are crisp. also my tab selected is blurry but all other text and buttons are crisp.

i must have gotten the new one cause i had the

BackgroundColor: "0xFF" Background
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

06 Apr 2022, 22:17

joekingcool wrote:
06 Apr 2022, 21:47
another issue i found was the x/y starting cord changes when you change the scaling. makes it a little difficult to match up with other buttons in the script.
If you are scaling the radios without scaling the whole gui you will need to use a offset for your x and y values.

Example:

Code: Select all

#Include, Gdip.ahk
#Include GlowRadio_1.ahk
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd -DPIScale
Gui, Color, 22262a
;######################################################################################################################################################################
scale := 3
Admin := New GlowRadio_1( { Scalefactor: scale , X: ( 10 / Scale ) , Y: ( ( Y := 10 ) / Scale )  } )
User := New GlowRadio_1( { Scalefactor: scale , X: ( 10 / Scale ) , Y: ( ( Y += Admin.H + 5 ) / Scale ) } )  ; info: [ ( ( Y += Admin.H + 5 ) / Scale ) } ) ] = Position this control 5px below the last one. This expression can be written on its own line if it is easier for you. i.e. [ var := blah blah blah ]
Other := New GlowRadio_1( { Scalefactor: scale , X: ( 10 / Scale ) , Y: ( ( Y += User.H + 5 ) / Scale ) } )
;######################################################################################################################################################################
Gui, Show,,Custom Radio Controls
return
**NOTE**
From the above example you can see that you only need to pass it the values that are different from the defaults located at the top of the class.
The simplest course of action is to set the defaults to the values that the radios will have in common and then when you create them you will only have to supply a few independent values.

**NOTE 2**
The input for a new radio is an object which can be created anywhere in your script. From a .ini file for example.


If you have any questions let me know. I have also seen your other post and will reply when I get the chance.
joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

07 Apr 2022, 00:30

ok i see what you mean. that works. although the text don't look as crisp as the buttons still.

i added a bubble button at about the same font size to compare. And yes i try to have variable's at beginning of script to control all fonts sizes colors and dimensions of the gui. so i can use to make new gui's quicker.

Code: Select all

global HB_Button:=[]
global Config:=[]

Config[9] := "Lucida Console"	;switch button font
Config[10] := "00FFFF"		;switch button font color
Config[11] := "21"		;switch button font size






#Include Gdip_All.ahk
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd
Gui, Color, % Background := "333333"
;######################################################################################################################################################################
scale := 1.3
Y_Offset := 1
X_Offset := 1
Gui, -DPIScale
Admin := New GlowRadio_1( { Scalefactor: scale , State: 1 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
User := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Other := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )

HB_Button.Push(New Bubble_Button(x:=0,y:=170,w:=170,h:=25,Window:="1",Text:="Some button",Label:="GuiClose"))

/*
;######################################################################################################################################################################
scale := 1.5
Y_Offset := 1
X_Offset := 2
OtherGroup := []
OtherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group2" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 2
Y_Offset := 1
X_Offset := 2
AnotherGroup := []
AnotherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group3" , Scalefactor: scale , State: 1 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "Waldo" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 3
Y_Offset := 1
X_Offset := 1
OneLastGroup := []
OneLastGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group4" , Scalefactor: scale , State: 0 , X: 130 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 1 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Gui, +DPIScale
;######################################################################################################################################################################
*/


Gui, Show,,Custom Radio Controls

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*********************************************************************************************************************************
;How to get the output from the radios
RALT::
	ToolTip, % "Selected item from Group 1: " Admin.GetSelected()
	
			. "`nThe text on the selected item is: " GlowRadio_1.Groups[ "Group1" ].Members[ Admin.GetSelected() ].Text
			
			. "`n`n`nSelected item from group 2: " OtherGroup[ 1 ].GetSelected()
			
			. "`n`nThe State of ""OneLastGroup[ 2 ]"" is: " OneLastGroup[ 2 ].State " [ " OneLastGroup[ 2 ].GetState() " ] "
	return
;*********************************************************************************************************************************

;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1	{
	;Written By: Hellbent
	;Date: Aprial 6th , 2022
	;Creates new instances of gui Radio controls and groups
	;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
	;Get Selected Item From Group Example: MyRadio..GetSelected()  ;(Returns the position of the selected radio in it's group )
	;Get The State Of A Radio Example: MyRadio.State    ;Or: MyRadio.GetState() 
	static init := GlowRadio_1._SetDefaults()
	_SetDefaults(){
		This.W := 11 
		This.H := 11
		This.Groups := {}
		This.Index := 0
		This.Settings := {}
		This.Settings.X := 10
		This.Settings.Y := 10
		This.Settings.W := 120
		This.Settings.H := 20
		This.Settings.Text := ""
		This.Settings.ActiveColor := "0xFF67D5D6"
		This.Settings.ButtonRestColor := "0xFF004444"
		This.Settings.RestColor := "0xFF009999"
		This.Settings.State := 0
		This.Settings.Font := "Arial"
		This.Settings.FontSize := 14
		This.Settings.FontOptions := " vCenter Left "
		This.Settings.BackgroundColor := "0xFF22262a"
		This.Settings.GroupName := "Group1"
		This.Settings.Owner := "1"
		This.Settings.GroupIndex := 1
		This.Settings.GroupSelected := 0
		This.Settings.ScaleFactor := 1
		This.Settings.Y_Offset := 5
		This.Settings.X_Offset := 1
	}
	__New( obj := "" ){
		
		This._CreateRadioObject( obj )
		This._CreateControl()
		if( This.State ){
			Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	{
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].State := 0
			}
			This.State := 1
		}
		Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	
			GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
	}
	_CreateRadioObject( obj := "" ){
		local k , v 
		for k , v in GlowRadio_1.Settings
			This[ k ] := v 
		if( IsObject( obj ) ){
			for k , v in obj 
				if( GlowRadio_1.Settings.HasKey( k ) )
					This[ k ] := v 
			if( obj.HasKey( "GroupName" ) )
				GlowRadio_1.Settings.GroupName := obj.GroupName
		}
	}
	_CreateControl(){
		local hwnd , bd
		Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
		This.Hwnd := hwnd
		++GlowRadio_1.Index
		If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
			GlowRadio_1.Groups[ This.GroupName ] := {}
			This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
			GlowRadio_1.Groups[ This.GroupName ].Members := []
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0 )
		}else{
			This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Selected )
		}
		GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
		bd := This._SwitchStates.Bind( This )
		GuiControl, % This.Owner ":+G" , % Hwnd , % bd
		GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
		GuiControl, % This.Owner ":Focus", % This.Hwnd
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.GroupSelected
	}
	_SwitchStates(){
		local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
		if( This.Index = GlowRadio_1.Groups[ This.GroupName ].LastSelected )
			return
		cc.Selected := This.Index
		Loop, % cc.Members.Length()	{
			cc.Members[ A_Index ].GroupSelected := cc.Selected
			cc.Members[ A_Index ].State := 0
		}
		This.State := 1
		cc.Members[ GlowRadio_1.Groups[ This.GroupName ].LastSelected ].Draw()
		This.Draw()
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.Index
		GuiControl, % This.Owner ":Focus", % This.Hwnd
	}
	GetState(){
		return 	This.State
	}
	GetSelected(){
		return This.GroupSelected
	}
	Draw(){
		;Bitmap Created Using: HB Bitmap Maker
		local ly := 0
		ScaleFactor := This.ScaleFactor
		pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;Outer ring
		Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
		;inner square
		Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;bottom layer of text
		if( This.State )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		else
			Brush := Gdip_BrushCreateSolid(  "0x000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" Floor( ( GlowRadio_1.W + 5 + 2 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		;top layer of text
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		SetImage( This.Hwnd , hBitmap )
		Gdip_DisposeImage( pBitmap )
		DeleteObject( hBitmap )
	}
}

;######################################################################################################################################
;#####################################################  Made by hellbent, tweaked by joe.king.cool  #######################################################
;#####################################################  	sec.function.Bubble_Button	    #######################################################
;#####################################################  					    #######################################################
;######################################################################################################################################
class Bubble_Button{
	__New( x := 10 , y := 10 , w := 150 , h := 40  , Window := "1", Text := "Button",Label := "" , Button_Color := "" , Button_Background_Color:= "" ,  Font := "Tahoma" , Font_Size := "16" , Font_Color_Top := "000000" , Font_Color_Bottom := "FFFFFF"  ){
		This.Text_Color_Top := "0xFF" Config[10] , This.Text_Color_Bottom := "0xFF000000" , This.Font := Config[9] , This.Font_Size := Config[11] 
		This.X := x , This.Y := y , This.W := w , This.H := h , This.Window := Window , This.Text := Text ,This.Label := Label, This.Button_Background_Color := "0xFF" Button_Background_Color , This.Button_Color := "0xFF" Button_Color 
		This.Create_Default_Bitmap() , This.Create_Hover_Bitmap() , This.Create_Pressed_Bitmap() , This.Create_Trigger()
		sleep, 20
		This.Draw_Default()
			}
	Create_Trigger(){
		global
		num := HB_Button.Length() + 1
		Gui , % This.Window ": Add" , Picture , % "x" This.X " y" This.Y " w" This.W " h" This.H " hwndHwnd_" Num " v" Num " g" This.Label " 0xE"
		This.Number := Num , This.Hwnd := Hwnd_%num%
	}
	Create_Default_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W, This.H )
		G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		if(This.Button_Color="0xFF000000"||This.Button_Color="0xFF111111")
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , "0xFF333333" , This.Button_Color , 1 , 1 )
		else
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , This.Button_Color , "0xFF333333" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0x22F0F0F0" )
		Gdip_FillEllipse( G , Brush , This.W/15 , This.H/13 , This.W-(This.W/15*2) , This.H*0.45 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x-1 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x0 y0" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Default_Bitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
		Gdip_DisposeImage(pBitmap)
	}

	Create_Hover_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W , This.H )
		 G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )

		Brush := Gdip_BrushCreateSolid( "0xFF" Config[3] )  
		Gdip_FillRoundedRectangle( G , Brush , 1 , -1 , This.W-2 , This.H+1 , Config[10] )
		Gdip_DeleteBrush( Brush )

		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , This.W-4 , This.H-3 , Config[10] )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , Config[10] )
		Gdip_DeleteBrush( Brush )
		if(This.Button_Color="0xFF000000"||This.Button_Color="0xFF111111")
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+10 , "0xFF444444" , This.Button_Color , 1 , 1 )
		else
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+10 , This.Button_Color , "0xFF444444" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , Config[10] )
		Gdip_DeleteBrush( Brush )


		Brush := Gdip_BrushCreateSolid( "0x22F0F0F0" )
		Gdip_FillEllipse( G , Brush , This.W/15 , This.H/13 , This.W-(This.W/15*2) , This.H*0.45 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x-1 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x0 y0" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Hover_Bitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
		Gdip_DisposeImage(pBitmap)
	}
	Create_Pressed_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W , This.H )
		 G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , 0 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , "0xFF333333" , This.Button_Color , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , 5 )
		Gdip_DeleteBrush( Brush )
		;Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		;Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x-1 y-2" , This.Font , This.W , This.H )
		;Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x0 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Pressed_Bitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
	}
	Draw_Default(){
		SetImage( This.Hwnd , This.Default_Bitmap )
	}
	Draw_Hover(){
		SetImage( This.Hwnd , This.Hover_Bitmap )
	}
	Draw_Pressed(){
		SetImage( This.Hwnd , This.Pressed_Bitmap )
		SetTimer , HB_Button_Hover , Off
		While( GetKeyState( "LButton" ) )
			sleep , 10
		SetTimer , HB_Button_Hover , On
		MouseGetPos,,,, ctrl , 2
		if( This.Hwnd != ctrl ){
			This.Draw_Default()
			return False
		}else	{
			This.Draw_Hover()
			return true
		}
	}
}

;######################################################################################################################################
;######################################################################################################################################
;#####################################################  Made by hellbent, tweaked by joe.king.cool  ###################################
;#####################################################  		sec.function.Hover 	    ###################################
;#####################################################  					    ###################################
;######################################################################################################################################
;######################################################################################################################################
HB_Button_Hover(){
	static Hover_On,Index
	MouseGetPos,,,,ctrl,2
	if(!Hover_On&&ctrl){
		Loop,% HB_Button.Length()	{
			if(ctrl=HB_Button[A_Index].Hwnd)
				HB_Button[A_Index].Draw_Hover(),Index:=A_Index,Hover_On:=1,break
		}
	}else if(Hover_On){
		if(HB_Button[Index].Hwnd!=ctrl)
			HB_Button[Index].Draw_Default(),Hover_On:=0
	}
}
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

07 Apr 2022, 01:20

joekingcool wrote:
07 Apr 2022, 00:30
ok i see what you mean. that works. although the text don't look as crisp as the buttons still.
Is this what you are looking for?

Code: Select all

global HB_Button:=[]
global Config:=[]

Config[9] := "Lucida Console"	;switch button font
Config[10] := "00FFFF"		;switch button font color
Config[11] := "21"		;switch button font size






#Include Gdip_All.ahk
#SingleInstance, Force
Gdip_Startup()
Gui, 1:New, +AlwaysOnTop HwndGuiHwnd -DPIScale ;<<<<<<<
Gui, Color, % Background := "444444"
;######################################################################################################################################################################
GlowRadio_1.Settings[ "ScaleFactor" ] 		:= 1.3
GlowRadio_1.Settings[ "Font" ] 				:= "Lucida Console"
GlowRadio_1.Settings[ "FontSize" ] 			:= 14
GlowRadio_1.Settings[ "FontOptions" ] 		:= " Left vCenter Bold "
GlowRadio_1.Settings[ "BackgroundColor" ] 	:= "0xFF" Background
GlowRadio_1.Settings[ "X_Offset" ] 			:= 1
GlowRadio_1.Settings[ "Y_Offset" ] 			:= 1.5

Admin := New GlowRadio_1( { State: 1 , Y: y := 10 , Text: "Admin" } )
User := New GlowRadio_1( { Y: y += 5 + Admin.H  , Text: "User" } )
Other := New GlowRadio_1( { Y: y += 5 + User.H , Text: "Other" } )
HB_Button.Push(New Bubble_Button(x:=0,y:=170,w:=170,h:=25,Window:="1",Text:="Some button",Label:="GuiClose"))
/*
;######################################################################################################################################################################
scale := 1.5
Y_Offset := 1
X_Offset := 2
OtherGroup := []
OtherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group2" , Scalefactor: scale , State: 1 , X: 130 , Y: y := 10 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OtherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 2
Y_Offset := 1
X_Offset := 2
AnotherGroup := []
AnotherGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group3" , Scalefactor: scale , State: 1 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + Admin.H  , Text: "Waldo" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
AnotherGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
;######################################################################################################################################################################
scale := 3
Y_Offset := 1
X_Offset := 1
OneLastGroup := []
OneLastGroup[ 1 ] := New GlowRadio_1( { GroupName: "Group4" , Scalefactor: scale , State: 0 , X: 130 , Y: y := 100 , Text: "Admin" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 2 ] := New GlowRadio_1( { Scalefactor: scale , State: 0 , X: 130 , Y: y += 5 + Admin.H  , Text: "User" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
OneLastGroup[ 3 ] := New GlowRadio_1( { Scalefactor: scale , State: 1 , X: 130 , Y: y += 5 + User.H , Text: "Other" , BackgroundColor: "0xFF" Background , Y_Offset: Y_Offset , X_Offset: X_Offset } )
Gui, +DPIScale
;######################################################################################################################################################################
*/


Gui, Show,,Custom Radio Controls

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*********************************************************************************************************************************
;How to get the output from the radios
RALT::
	ToolTip, % "Selected item from Group 1: " Admin.GetSelected()
	
			. "`nThe text on the selected item is: " GlowRadio_1.Groups[ "Group1" ].Members[ Admin.GetSelected() ].Text
			
			. "`n`n`nSelected item from group 2: " OtherGroup[ 1 ].GetSelected()
			
			. "`n`nThe State of ""OneLastGroup[ 2 ]"" is: " OneLastGroup[ 2 ].State " [ " OneLastGroup[ 2 ].GetState() " ] "
	return
;*********************************************************************************************************************************

;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1	{
	;Written By: Hellbent
	;Date: Aprial 6th , 2022
	;Creates new instances of gui Radio controls and groups
	;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
	;Get Selected Item From Group Example: MyRadio..GetSelected()  ;(Returns the position of the selected radio in it's group )
	;Get The State Of A Radio Example: MyRadio.State    ;Or: MyRadio.GetState() 
	static init := GlowRadio_1._SetDefaults()
	_SetDefaults(){
		This.W := 11 
		This.H := 11
		This.Groups := {}
		This.Index := 0
		This.Settings := {}
		This.Settings.X := 10
		This.Settings.Y := 10
		This.Settings.W := 120
		This.Settings.H := 20
		This.Settings.Text := ""
		This.Settings.ActiveColor := "0xFF67D5D6"
		This.Settings.ButtonRestColor := "0xFF004444"
		This.Settings.RestColor := "0xFF009999"
		This.Settings.State := 0
		This.Settings.Font := "Arial"
		This.Settings.FontSize := 14
		This.Settings.FontOptions := " vCenter Left "
		This.Settings.BackgroundColor := "0xFF22262a"
		This.Settings.GroupName := "Group1"
		This.Settings.Owner := "1"
		This.Settings.GroupIndex := 1
		This.Settings.GroupSelected := 0
		This.Settings.ScaleFactor := 1
		This.Settings.Y_Offset := 5
		This.Settings.X_Offset := 1
	}
	__New( obj := "" ){
		
		This._CreateRadioObject( obj )
		This._CreateControl()
		if( This.State ){
			Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	{
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
				GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].State := 0
			}
			This.State := 1
		}
		Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()	
			GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
	}
	_CreateRadioObject( obj := "" ){
		local k , v 
		for k , v in GlowRadio_1.Settings
			This[ k ] := v 
		if( IsObject( obj ) ){
			for k , v in obj 
				if( GlowRadio_1.Settings.HasKey( k ) )
					This[ k ] := v 
			if( obj.HasKey( "GroupName" ) )
				GlowRadio_1.Settings.GroupName := obj.GroupName
		}
	}
	_CreateControl(){
		local hwnd , bd
		Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
		This.Hwnd := hwnd
		++GlowRadio_1.Index
		If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
			GlowRadio_1.Groups[ This.GroupName ] := {}
			This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
			GlowRadio_1.Groups[ This.GroupName ].Members := []
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0 )
		}else{
			This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
			( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Selected )
		}
		GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
		bd := This._SwitchStates.Bind( This )
		GuiControl, % This.Owner ":+G" , % Hwnd , % bd
		GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
		GuiControl, % This.Owner ":Focus", % This.Hwnd
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.GroupSelected
	}
	_SwitchStates(){
		local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
		if( This.Index = GlowRadio_1.Groups[ This.GroupName ].LastSelected )
			return
		cc.Selected := This.Index
		Loop, % cc.Members.Length()	{
			cc.Members[ A_Index ].GroupSelected := cc.Selected
			cc.Members[ A_Index ].State := 0
		}
		This.State := 1
		cc.Members[ GlowRadio_1.Groups[ This.GroupName ].LastSelected ].Draw()
		This.Draw()
		GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.Index
		GuiControl, % This.Owner ":Focus", % This.Hwnd
	}
	GetState(){
		return 	This.State
	}
	GetSelected(){
		return This.GroupSelected
	}
	Draw(){
		;Bitmap Created Using: HB Bitmap Maker
		local ly := 0
		ScaleFactor := This.ScaleFactor
		pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;Outer ring
		Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
		;inner square
		Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
		;bottom layer of text
		if( This.State ){
			;~ Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			arrX := [ -2 , -1 , 0 , -2 , -1 , 0 , -2 , -1 , 0 ]
			arrY := [ -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 ]
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			Brush := Gdip_BrushCreateSolid( "0xFF000000" )
			ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) )
			Loop, 9	
				Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) + arrX[ A_Index ] " y" ly + arrY[ A_Index ] , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) 
			Gdip_DeleteBrush( Brush )
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		}else 
			ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) + 1
		
		
		;top layer of text
		Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		SetImage( This.Hwnd , hBitmap )
		Gdip_DisposeImage( pBitmap )
		DeleteObject( hBitmap )
	}
}

;######################################################################################################################################
;#####################################################  Made by hellbent, tweaked by joe.king.cool  #######################################################
;#####################################################  	sec.function.Bubble_Button	    #######################################################
;#####################################################  					    #######################################################
;######################################################################################################################################
class Bubble_Button{
	__New( x := 10 , y := 10 , w := 150 , h := 40  , Window := "1", Text := "Button",Label := "" , Button_Color := "" , Button_Background_Color:= "" ,  Font := "Tahoma" , Font_Size := "16" , Font_Color_Top := "000000" , Font_Color_Bottom := "FFFFFF"  ){
		This.Text_Color_Top := "0xFF" Config[10] , This.Text_Color_Bottom := "0xFF000000" , This.Font := Config[9] , This.Font_Size := Config[11] 
		This.X := x , This.Y := y , This.W := w , This.H := h , This.Window := Window , This.Text := Text ,This.Label := Label, This.Button_Background_Color := "0xFF" Button_Background_Color , This.Button_Color := "0xFF" Button_Color 
		This.Create_Default_Bitmap() , This.Create_Hover_Bitmap() , This.Create_Pressed_Bitmap() , This.Create_Trigger()
		sleep, 20
		This.Draw_Default()
			}
	Create_Trigger(){
		global
		num := HB_Button.Length() + 1
		Gui , % This.Window ": Add" , Picture , % "x" This.X " y" This.Y " w" This.W " h" This.H " hwndHwnd_" Num " v" Num " g" This.Label " 0xE"
		This.Number := Num , This.Hwnd := Hwnd_%num%
	}
	Create_Default_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W, This.H )
		G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		if(This.Button_Color="0xFF000000"||This.Button_Color="0xFF111111")
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , "0xFF333333" , This.Button_Color , 1 , 1 )
		else
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , This.Button_Color , "0xFF333333" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0x22F0F0F0" )
		Gdip_FillEllipse( G , Brush , This.W/15 , This.H/13 , This.W-(This.W/15*2) , This.H*0.45 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x-1 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x0 y0" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Default_Bitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
		Gdip_DisposeImage(pBitmap)
	}

	Create_Hover_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W , This.H )
		 G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )

		Brush := Gdip_BrushCreateSolid( "0xFF" Config[3] )  
		Gdip_FillRoundedRectangle( G , Brush , 1 , -1 , This.W-2 , This.H+1 , Config[10] )
		Gdip_DeleteBrush( Brush )

		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 2 , This.W-4 , This.H-3 , Config[10] )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , Config[10] )
		Gdip_DeleteBrush( Brush )
		if(This.Button_Color="0xFF000000"||This.Button_Color="0xFF111111")
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+10 , "0xFF444444" , This.Button_Color , 1 , 1 )
		else
			Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+10 , This.Button_Color , "0xFF444444" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , Config[10] )
		Gdip_DeleteBrush( Brush )


		Brush := Gdip_BrushCreateSolid( "0x22F0F0F0" )
		Gdip_FillEllipse( G , Brush , This.W/15 , This.H/13 , This.W-(This.W/15*2) , This.H*0.45 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x-1 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x0 y0" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Hover_Bitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
		Gdip_DisposeImage(pBitmap)
	}
	Create_Pressed_Bitmap(){
		pBitmap:=Gdip_CreateBitmap( This.W , This.H )
		 G := Gdip_GraphicsFromImage( pBitmap )
		Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
		Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+2 , This.H+2 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF222222" )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 2 , 0 , This.W-4 , This.H-3 , "0xFF555555" , "0xFF000000" , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 2 , 0 , This.W-4 , This.H-3 , 5 )
		Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 4 , -1 , This.W-6 , This.H+5 , "0xFF333333" , This.Button_Color , 1 , 1 )
		Gdip_FillRoundedRectangle( G , Brush , 3 , 1 , This.W-6 , This.H-5 , 5 )
		Gdip_DeleteBrush( Brush )
		;Brush := Gdip_BrushCreateSolid( This.Text_Color_Bottom )
		;Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x-1 y-2" , This.Font , This.W , This.H )
		;Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.Text_Color_Top )
		Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter Bold c" Brush " x0 y-1" , This.Font , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		This.Pressed_Bitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
	}
	Draw_Default(){
		SetImage( This.Hwnd , This.Default_Bitmap )
	}
	Draw_Hover(){
		SetImage( This.Hwnd , This.Hover_Bitmap )
	}
	Draw_Pressed(){
		SetImage( This.Hwnd , This.Pressed_Bitmap )
		SetTimer , HB_Button_Hover , Off
		While( GetKeyState( "LButton" ) )
			sleep , 10
		SetTimer , HB_Button_Hover , On
		MouseGetPos,,,, ctrl , 2
		if( This.Hwnd != ctrl ){
			This.Draw_Default()
			return False
		}else	{
			This.Draw_Hover()
			return true
		}
	}
}

;######################################################################################################################################
;######################################################################################################################################
;#####################################################  Made by hellbent, tweaked by joe.king.cool  ###################################
;#####################################################  		sec.function.Hover 	    ###################################
;#####################################################  					    ###################################
;######################################################################################################################################
;######################################################################################################################################
HB_Button_Hover(){
	static Hover_On,Index
	MouseGetPos,,,,ctrl,2
	if(!Hover_On&&ctrl){
		Loop,% HB_Button.Length()	{
			if(ctrl=HB_Button[A_Index].Hwnd)
				HB_Button[A_Index].Draw_Hover(),Index:=A_Index,Hover_On:=1,break
		}
	}else if(Hover_On){
		if(HB_Button[Index].Hwnd!=ctrl)
			HB_Button[Index].Draw_Default(),Hover_On:=0
	}
}
joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

07 Apr 2022, 09:54

@Hellbent

the bold does look better. can you make the selected one brighter like the buttons?
dbgba
Posts: 20
Joined: 02 Apr 2021, 22:11

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

23 Apr 2022, 03:39

TheDewd wrote:
15 Jan 2016, 16:57
I have attempted to create a UI similar to the one from my last post in this thread. I'm using less code this time, and there are no external images required.

This Gui is a work in progress. In case you're curious, the design is a reproduction of the PeaZip options screen, with some occasional modifications. If you think you know a better way to code any part of my script, please let me know. I've already went through several revisions of the code to make it respond better to user interaction and make the code less complex, but I'm still willing to hear suggestions for improvement. Thanks!

Screenshot.png

Code: Select all

; Globals ======================================================================
#SingleInstance, Force ; Replace with new instance if script is running
#Persistent ; Keep script permanently running until terminated
#NoEnv ; Prevent identifying empty variables as potential environment variables
#Warn ; Enable warnings to assist with detecting errors
;#NoTrayIcon ; Disable the tray icon of the script
SendMode, Input ; Method for sending keystrokes and mouse clicks
SetWorkingDir, %A_ScriptDir% ; The current working directory of the script

Application := {Name: "Menu Interface", Version: "0.1"}
Window := {Width: 600, Height: 400, Title: Application.Name}
Navigation := {Label: ["General", "Advanced", "Language", "Theme", "---", "Help", "About"]}
; ==============================================================================

; Auto-Execute =================================================================
Menu, Tray, Icon, Shell32.dll, 174
Menu, Tray, Tip, % Application.Name
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, ExitSub

Gui, +LastFound -Resize +HwndhGui1
Gui, Color, FFFFFF

Gui, Add, Tab2, % " x" -999999 " y" -999999 " w" 0 " h" 0 " -Wrap +Theme vTabControl", % ""

Gui, Tab ; Exclude future controls from any tab control

Gui, Add, Picture, % "x" -999999 " y" -999999 " w" 4 " h" 32 " vpMenuHover +0x4E +HWNDhMenuHover",
Gui, Add, Picture, % "x" 0 " y" 18 " w" 4 " h" 32 " vpMenuSelect +0x4E +HWNDhMenuSelect",

Gui, Font, s9 c808080, Segoe UI ; Set Font Options
Loop, % Navigation.Label.Length() {
	GuiControl,, TabControl, % Navigation.Label[A_Index] "|"
	If (Navigation.Label[A_Index] = "---") {
		Continue
	}
	Gui, Add, Text, % "x" 18 " y" (32*A_Index)-14 " h" 32 " +0x200 gMenuClick vMenuItem" . A_Index, % Navigation.Label[A_Index]
}
Gui, Font ; Reset font options

Gui, Font, s11 c000000, Segoe UI ; Set Font Options
Gui, Add, Text, % "x" 192 " y" 18 " w" (Window.Width-192)-14 " h" 32 " +0x200 vPageTitle", % ""
Gui, Font ; Reset font options

Gui, Add, Picture, % "x" 192 " y" 50 " w" (Window.Width-192)-14 " h" 1 " +0x4E +HWNDhDividerLine",

Gui, Add, Button, % "x" (Window.Width-170)-10 " y" (Window.Height-24)-10 " w" 80 " h" 24 " vButtonOK", % "OK"
Gui, Add, Button, % "x" (Window.Width-80)-10 " y" (Window.Height-24)-10 " w" 80 " h" 24 " vButtonCancel", % "Cancel"

Gui, Tab, 1 ; Future controls are owned by the specified tab
Gui, Add, Checkbox, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "Checkbox Example"

Gui, Tab, 2 ; Future controls are owned by the specified tab
Gui, Add, ListView, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "Col1|Col2"
LV_Add("", "ListView", "Example")
LV_ModifyCol()

Gui, Tab, 3 ; Future controls are owned by the specified tab
Gui, Add, MonthCal, % "x" 192 " y" 66

Gui, Tab, 4 ; Future controls are owned by the specified tab
Gui, Add, DateTime, % "x" 192 " y" 66, LongDate

Gui, Tab, 5 ; Future controls are owned by the specified tab
; Skipped

Gui, Tab, 6 ; Future controls are owned by the specified tab
Gui, Add, GroupBox, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "GroupBox"

Gui, Tab, 7 ; Future controls are owned by the specified tab
Gui, Add, DateTime, % "x" 192 " y" 66, LongDate

Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title

GoSub, OnLoad
return ; End automatic execution
; ==============================================================================

; Labels =======================================================================
OnLoad:
	SetPixelColor("CCEEFF", hMenuHover)
	SetPixelColor("3399FF", hMenuSelect)
	SetPixelColor("D8D8D8", hDividerLine)
	SelectMenu("MenuItem1")
	OnMessage(0x200, "WM_MOUSEMOVE")
return

MenuClick:
	SelectMenu(A_GuiControl)
return

GuiEscape:
GuiClose:
ButtonOK:
ButtonCancel:
ExitSub:
	ExitApp ; Terminate the script unconditionally
return
; ==============================================================================

; Functions ====================================================================
SelectMenu(Control) {
	Global

	CurrentMenu := Control

	Loop, % Navigation.Label.Length() {
		SetControlColor("808080", Navigation.Label[A_Index])
	}

	SetControlColor("000000", Control)
	GuiControl, Move, pMenuSelect, % "x" 0 " y" (32*SubStr(Control, 9, 2))-14 " w" 4 " h" 32
	GuiControl, Choose, TabControl, % SubStr(Control, 9, 2)
	GuiControl,, PageTitle, % Navigation.Label[SubStr(Control, 9, 2)]
}

WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
	Global

	If (InStr(A_GuiControl, "MenuItem") = true && A_GuiControl != CurrentMenu) {
		GuiControl, Move, pMenuHover, % "x" 0 " y" (32*SubStr(A_GuiControl, 9, 2))-14 " w" 4 " h" 32
	} Else If (InStr(A_GuiControl, "MenuItem") = false || A_GuiControl = CurrentMenu) {
		GuiControl, Move, pMenuHover, % "x" -999999 " y" -999999 " w" 4 " h" 32
	}
}

SetControlColor(Color, Control) {
	Global

	GuiControl, % "+c" Color, % Control

	; Required due to redrawing issue with Tab2 control
	GuiControlGet, ControlText,, % Control
	GuiControlGet, ControlHandle, Hwnd, % Control
	DllCall("SetWindowText", "Ptr", ControlHandle, "Str", ControlText)
}

SetPixelColor(Color, Handle) {
	VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt")
	hBM := DllCall("Gdi32.dll\CreateBitmap", Int, 1, Int, 1, UInt, 1, UInt, 24, Ptr, 0)
	hBM := DllCall("User32.dll\CopyImage", Ptr, hBM, UInt, 0, Int, 0, Int, 0, UInt, 0x2008)
	DllCall("Gdi32.dll\SetBitmapBits", Ptr, hBM, UInt, 3, Ptr, &BMBITS)
	return DllCall("User32.dll\SendMessage", Ptr, Handle, UInt, 0x172, Ptr, 0, Ptr, hBM)
}
; ==============================================================================

Thanks to @TheDewd for sharing, I have further improved this Gui template based on it. More modifications and additions to it are welcome!

png20220423162941.png
png20220423162941.png (46.97 KiB) Viewed 5249 times

Code: Select all

#Persistent
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Menu, Tray, Icon, Shell32.dll, 174

Window := {Width: 590, Height: 390, Title: "Menu Interface"}  ; Version: "0.2"
Navigation := {Label: ["General", "Advanced", "Language", "Theme", "---", "Help", "About"]}

Gui +LastFound -Resize +HwndhGui
Gui Color, FFFFFF
Gui Add, Picture, x0 y0 w1699 h1 +0x4E +HWNDhDividerLine1  ; Dividing line From left to right [top menu bar]

Gui Add, Tab2, x-666 y10 w1699 h334 -Wrap +Theme Buttons vTabControl
Gui Tab

Gui Add, Picture, % "x" -9999 " y" -9999 " w" 96 " h" 32 " vpMenuHover +0x4E +HWNDhMenuHover" ; Menu Hover
Gui Add, Picture, % "x" 0 " y" 18 " w" 4 " h" 32 " vpMenuSelect +0x4E +HWNDhMenuSelect" ; Menu Select

Gui Add, Picture, x96 y0 w1 h1340 +0x4E +HWNDhDividerLine3  ; Divider Top to bottom
Gui Add, Progress, x0 y0 w96 h799 +0x4000000 +E0x4 Disabled BackgroundF7F7F7 ; Left side constant background color

; Font size and font boldness for the left Tab header
Gui Font, W600 Q5 c808080, Segoe UI
Loop % Navigation.Label.Length() {
	GuiControl,, TabControl, % Navigation.Label[A_Index] "|"
	If (Navigation.Label[A_Index] = "---")
		Continue

	Gui Add, Text, % "x" 0 " y" (32*A_Index)-24 " h" 32 " w" 96 " Center +0x200 BackgroundTrans gMenuClick vMenuItem" . A_Index, % Navigation.Label[A_Index]
}
Gui Font

; Bottom button and background
Global HtmlButton1, HtmlButton2

NewButton1 := New HtmlButton("HtmlButton1", "OK", "Button1_", (Window.Width-176)-20, (Window.Height-24)-14)
NewButton2 := New HtmlButton("HtmlButton2", "Cancel", "Button1_", (Window.Width-80)-20, (Window.Height-24)-14)

; Gui Add, Button, % "x" (Window.Width-176)-20 " y" (Window.Height-24)-14 " w78 h26 vButtonOK", OK
; Gui Add, Button, % "x" (Window.Width-80)-20 " y" (Window.Height-24)-14 " w78 h26 vButtonCancel", Cancel

Gui Add, Picture, x96 y340 w1001 h1 +0x4E +HWNDhDividerLine4  ; Dividing line From left to right [Bottom]
Gui Add, Progress, x0 y340 w1502 h149 +0x4000000 +E0x4 Disabled BackgroundFBFBFB


; Font size of the top right Tab title
Gui Font, s15 Q5 c000000, Segoe UI
Gui Add, Text, % "x" 117 " y" 4 " w" (Window.Width-110)-16 " h32 +0x200 vPageTitle"
Gui Add, Picture, % "x" 110 " y" 38 " w" (Window.Width-110)-16 " h1 +0x4E +HWNDhDividerLine2"  ; Dividing Line
Gui Font

Gui Tab, 1
Gui Font, W560, Segoe UI
Gui Add, Text, Section x116 y50 BackgroundWhite, Select your primary button
Gui Font
Gui Add, DropDownList, xs+10 w80 vPrimaryButton Choose1, Left||Right
Gui Font, W560, Segoe UI
Gui Add, Text, xs yp+40, Cursor Speed
Gui Font
Gui Add, Slider, vMySlider NoTicks, 50
Gui Font, W560, Segoe UI
Gui Add, Text, yp+40 , Roll the mouse wheel to scrol
Gui Font
Gui Add, Radio, xs+10 yp+22 h14 Checked, Multiple lines at a time
Gui Add, Radio, xs+10 y+8 h14, On screen at a time
Gui Font, W560, Segoe UI
Gui Add, Checkbox, xs yp+36 h14, Mouse Button Tips
Gui Font

Gui Tab, 2
Gui Add, ListView, % "x" 116 " y" 50 " w" (Window.Width-110)-30, Col1|Col2
LV_Add("", "ListView", "Example"), LV_ModifyCol()

Gui Tab, 3
Gui Add, MonthCal, % "x" 116 " y" 50

Gui Tab, 4
Gui Add, DateTime, % "x" 116 " y" 50, LongDate

Gui Tab, 5  ; Skipped

Gui Tab, 6
Gui Add, GroupBox, % "x" 116 " y" 50 " w" (Window.Width-110)-30, GroupBox

Gui Tab, 7
Gui Add, TreeView, % "x" 116 " y" 50 " w220 h148"
P1 := TV_Add("First parent"), P1C1 := TV_Add("Parent 1's first child", P1)

Gui Show, % " w" Window.Width " h" Window.Height, % Window.Title

SetPixelColor("E9E9E9", hMenuHover)
SetPixelColor("0078D7", hMenuSelect)
Loop 4
    SetPixelColor("D8D8D8", hDividerLine%A_Index%)
SelectMenu("MenuItem1")
OnMessage(0x200, "WM_MOUSEMOVE")
Return

MenuClick:
	SelectMenu(A_GuiControl)
Return

GuiClose:
	ExitApp

; HtmlButton Event Handling
Button1_OnClick() {
	ExitApp
}

SelectMenu(Control) {
	Global
    Loop % Navigation.Label.Length()
        SetControlColor("808080", Navigation.Label[A_Index])  ; Color of the unchecked button on the left

	CurrentMenu := Control
	, SetControlColor("237FFF", Control)  ; Color of the selected button on the left
	GuiControl, Move, pMenuSelect, % "x" 0 " y" (32*SubStr(Control, 9, 2))-20 " w" 4 " h" 24
	GuiControl, Choose, TabControl, % SubStr(Control, 9, 2)
	GuiControl,, PageTitle, % Navigation.Label[SubStr(Control, 9, 2)]
}

WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
	Global hMenuSelect
    Static hover := {}

    if (wParam = "timer") {
        MouseGetPos,,,, hControl, 2
        if (hControl != hwnd) && (hControl != hMenuSelect) {
            SetTimer,, Delete
            GuiControl, Move, pMenuHover, % "x" -9999 " y" -9999
            OnMessage(0x200, "WM_MOUSEMOVE")
            , hover[hwnd] := False
        }
     } else {
        if (InStr(A_GuiControl, "MenuItem") = True) {
            GuiControl, Move, pMenuHover, % "x" 0 " y" (32*SubStr(A_GuiControl, 9, 2))-24
            GuiControl, MoveDraw, pMenuHover
            hover[hwnd] := True
            , OnMessage(0x200, "WM_MOUSEMOVE", 0)
            , timer := Func(A_ThisFunc).Bind("timer", "", "", hwnd)
            SetTimer % timer, 15
        } else if (InStr(A_GuiControl, "MenuItem") = False)
            GuiControl, Move, pMenuHover, % "x" -9999 " y" -9999
    }
}

SetControlColor(Color, Control) {
	GuiControl, % "+c" Color, % Control

	; Required due to redrawing issues with the Tab2 control
	GuiControlGet, ControlText,, % Control
	GuiControlGet, ControlHandle, Hwnd, % Control
	DllCall("SetWindowText", "Ptr", ControlHandle, "Str", ControlText)
    GuiControl, MoveDraw, % Control
}

SetPixelColor(Color, Handle) {
	VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt")
	, hBM := DllCall("Gdi32.dll\CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0)
	, hBM := DllCall("User32.dll\CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008)
	, DllCall("Gdi32.dll\SetBitmapBits", "Ptr", hBM, "UInt", 3, "Ptr", &BMBITS)
	return DllCall("User32.dll\SendMessage", "Ptr", Handle, "UInt", 0x172, "Ptr", 0, "Ptr", hBM)
}

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3851&start=360#p458266
; Replace the standard button with a web button style, compatible to XP system. If Gui turns on -DPIScale, you need to set the last parameter "DPIScale" of HtmlButton to non-0 to fix the match.
Class HtmlButton
{
	__New(ButtonGlobalVar, ButtonName, gLabelFunc, OptionsOrX:="", y:="", w:=78 , h:=26, GuiLabel:="", TextColor:="001C30", DPIScale:=False) {
		Static Count:=0
        f := A_Temp "\" A_TickCount "-tmp" ++Count ".DELETEME.html"

		Html_Str =
		(
			<!DOCTYPE html><html><head>
			<meta http-equiv="X-UA-Compatible" content="IE=edge">
			<style>body {overflow-x:hidden;overflow-y:hidden;}
				button { color: #%TextColor%;
					background-color: #F4F4F4;
					border-radius:2px;
					border: 1px solid #A7A7A7;
					cursor: pointer; }
				button:hover {background-color: #BEE7FD;}
			</style></head><body>
			<button id="MyButton%Count%" style="position:absolute;left:0px;top:0px;width:%w%px;height:%h%px;font-size:12px;font-family:'Microsoft YaHei UI';">%ButtonName%</button></body></html>
		)
        if (OptionsOrX!="")
            if OptionsOrX is Number
                x := "x" OptionsOrX
             else
                Options := " " OptionsOrX
        (y != "" && y := " y" y)
		Gui, %GuiLabel%Add, ActiveX, %  x . y . " w" w " h" h " v" ButtonGlobalVar . Options, Shell.Explorer
		FileAppend, % Html_Str, % f
		%ButtonGlobalVar%.Navigate("file://" . f)
        , this.Html_Str := Html_Str
        , this.ButtonName := ButtonName
        , this.gLabelFunc := gLabelFunc
        , this.Count := Count 
		, %ButtonGlobalVar%.silent := True
        , this.ConnectEvents(ButtonGlobalVar, f)
        if !DPIScale
            %ButtonGlobalVar%.ExecWB(63, 1, Round((A_ScreenDPI/96*100)*A_ScreenDPI/96) ) ; Fix ActiveX control DPI scaling
	}

    Text(ButtonGlobalVar, ButtonText) {
        Html_Str := StrReplace(this.Html_Str, ">" this.ButtonName "</bu", ">" ButtonText "</bu")
        FileAppend, % Html_Str, % f := A_Temp "\" A_TickCount "-tmp.DELETEME.html"
		%ButtonGlobalVar%.Navigate("file://" . f)
        , this.ConnectEvents(ButtonGlobalVar, f)
    }

    ConnectEvents(ButtonGlobalVar, f) {
		While %ButtonGlobalVar%.readystate != 4 or %ButtonGlobalVar%.busy
			Sleep 5
        this.MyButton := %ButtonGlobalVar%.document.getElementById("MyButton" this.Count)
		, ComObjConnect(this.MyButton, this.gLabelFunc)
		FileDelete, % f
    }
}
kazhafeizhale
Posts: 77
Joined: 25 Dec 2018, 10:58

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

30 Apr 2022, 07:13

gif.gif
gif.gif (728.66 KiB) Viewed 5147 times
elbitjusticiero
Posts: 78
Joined: 06 May 2017, 11:07

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

14 Jun 2022, 08:03

kazhafeizhale wrote:
30 Apr 2022, 07:13
gif.gif
Can you share your code for this?
User avatar
joedf
Posts: 8988
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

15 Jun 2022, 09:34

@dbgba I like it! :+1:
@kazhafeizhale fancy animated work ahaha
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
kazhafeizhale
Posts: 77
Joined: 25 Dec 2018, 10:58

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

27 Jul 2022, 10:24

image.png
image.png (1.05 MiB) Viewed 4587 times
a searchbox for text, if ahk code can exacute
https://github.com/kazhafeizhale/supper_command
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

13 Oct 2022, 16:17

Simple scalable custom gui [ GDI+ ]
Pixel Pred 4.1 1.gif
Pixel Pred 4.1 1.gif (743.78 KiB) Viewed 4152 times
Azzoc
Posts: 2
Joined: 24 Oct 2022, 03:57

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

24 Oct 2022, 04:14

Hellbent wrote:
13 Oct 2022, 16:17
Simple scalable custom gui [ GDI+ ]

Pixel Pred 4.1 1.gif
Sir, did you released your pixel prod work?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 35 guests