Rotary knob

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Rotary knob

13 Jul 2021, 12:22

Hi all, this rotary knob found here is very nice, except it has no color.
Is there an easy way to add color to it?
https://www.autohotkey.com/boards/viewtopic.php?t=77311

Here is the code

Code: Select all

Gui, Color, Black 
SetBatchLines -1
hGui := WinExist()
Gui, +Lastfound 

size=75 ; Works best between 35 and 150
PotNow = 0

Gui, add, Text, x2 y5 h%size% w%size% hwndhText1 gt1, 
Gui, Add, Progress, x5 y+5 w%size% cBlue Range0-360 vp1, %PotNow%

Gui, Show,  , 1 Pot

RotaryKnob(hText1,size,PotNow,1)
Return

t1:
MouseGetPos, , OutY
StartPoint := OutY
Loop, 
	{
	KeyIsDown := GetKeyState("LButton")
	If KeyIsDown = 1
		{
		MouseGetPos, , OutY
		PotSet := StartPoint-OutY+PotNow
		
		If PotSet < 0
			PotSet = 0
		If PotSet > 360
			PotSet = 360
		RotaryKnob(hText1,size,PotSet,1)
		GuiControl, , p1, %PotSet%
		Sleep, 50
		}
	If KeyIsDown = 0
		{
		PotNow := PotSet
		Break
		}
	}
Return
GuiEscape:
Esc::
 ExitApp

; Oringal concept by ahklerner
; https://autohotkey.com/board/topic/64700-rotary-knob-for-a-gui/#entry408451
; Edited to be used as a library function by x32
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77311

RotaryKnob(hWnd,Size,angle,tn)
	{
	Global
	x = 1
	y = 1
	canvas_size := Size
	knob_size := canvas_size * 1.05
	indicator_size := canvas_size /9
	GetXY(pos_x := x+(knob_size/2)-4,pos_y := y+(knob_size/2)-4, knob_size / 3, angle)
	hDc := DllCall("GetDC", "uint", hText%tn%)
	DllCall("Ellipse", "uint", hDc, "int", x, "int", y, "int", knob_size, "int", knob_size)
	DllCall("Ellipse", "uint", hDc, "int", x+2, "int", y+2, "int", knob_size-2, "int", knob_size-2)
	DllCall("Ellipse", "uint", hDc, "int", pos_x, "int", pos_y, "int", pos_x + indicator_size, "int", pos_y + indicator_size)
	}

GetXY(Byref x0, byref y0, r, angle)
	{
	x0 := x0-sin(angle*4*ATan(1)/180)*r
	y0 := y0+cos(angle*4*ATan(1)/180)*r
	}
    
User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: Rotary knob

13 Jul 2021, 17:03

Had you seen this: https://www.autohotkey.com/boards/viewtopic.php?t=6947 ? You might want to use GDIP instead and use this as an example.
14.3 & 1.3.7
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

13 Jul 2021, 17:24

Great. Thanks, flyingDman. I will try that.
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

13 Jul 2021, 19:36

This is a prototype for a dial control I made a few years ago. You might find something useful in it.

This version requires Windows 8 or higher to run.

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance,Force
SetBatchLines,-1
OnExit,GuiClose
Coordmode,Mouse,Client
Win:={X:0,Y:0,W:500,H:500}
Gui,1:+AlwaysOnTop -DPIScale 
Gui,1:Color,111111
Gui,1:Show,% "w" Win.W " h" Win.H ,Test Dial Control
Win:=Layered_Window_SetUp(4,Win.X,Win.Y,Win.W,Win.H,2,"+Parent1 -Caption -DPIScale +Alwaysontop +E0x20 ")
UpdateLayeredWindow(Win.hwnd, Win.hdc, 0, 0, Win.W, Win.H)
pen1:=New_Pen("777700"),pen2:=New_Pen("881111",,"7"),brush1:=New_Brush("881111"),brush2:=New_Brush("111111"),brush3:=New_Brush("777700")
Gui,1:Add,Text,cwhite x240 y240 w80 h80 Center gCheck,
Gui,1:Add,Edit,x340 y280 w50 h20 Center Disabled vEdit
gosub,first_Draw
return
GuiClose:
*^ESC::
	Layered_Window_ShutDown(Win)
	ExitApp
Check:
	While(GetKeyState("LButton")){
		MouseGetPos,tx,ty
		Gdip_GraphicsClear(Win.g) 
		Pi:=3.14159265359
		x:=tx-280,y:=ty-280
		Angle := dllcall("msvcrt\atan2","Double",y, "Double",x, "CDECL Double") * 180/Pi *-1 
		Val:= (Angle-180)  *-1 
		if(val>315)
			val:=0
		else if(val>270)
			val:=270
		out:=Round(Val/270*100)
		GuiControl,1:,Edit,% Out
		Gdip_FillEllipse(Win.g,Brush3,238,238,84,84)
		Gdip_FillEllipse(Win.g,Brush2,240,240,80,80)
		Gdip_DrawArc(Win.G,Pen2,245,245, 70, 70,180, 360)
		Gdip_DrawArc(Win.G,Pen2,250,250, 60, 60,180, -90)
		Gdip_DrawArc(Win.G,Pen1,250,250, 60, 60,180, Val)
		Gdip_FillEllipse(Win.g,Brush1,252,252,56,56)
		UpdateLayeredWindow(Win.hwnd, Win.hdc)
		Sleep,20
	}
	;~ SoundSet,%out%
	return

first_Draw:
	GuiControl,1:,Edit,1
	Gdip_FillEllipse(Win.g,Brush3,238,238,84,84)
	Gdip_FillEllipse(Win.g,Brush2,240,240,80,80)
	Gdip_DrawArc(Win.G,Pen2,245,245, 70, 70,0, 360)
	Gdip_DrawArc(Win.G,Pen2,250,250, 60, 60,180, -90)
	Gdip_DrawArc(Win.G,Pen1,250,250, 60, 60,180, 5)
	Gdip_FillEllipse(Win.g,Brush1,252,252,56,56)
	UpdateLayeredWindow(Win.hwnd, Win.hdc)
	return
;~ /*
Layered_Window_SetUp(Smoothing,Window_X,Window_Y,Window_W,Window_H,Window_Name:=1,Window_Options:=""){
	Layered:={}
	Layered.W:=Window_W,Layered.H:=Window_H,Layered.X:=Window_X,Layered.Y:=Window_Y,Layered.Name:=Window_Name,Layered.Options:=Window_Options
	Layered.Token:=Gdip_Startup()
	Create_Layered_GUI(Layered)
	Layered.hwnd:=winExist()
	Layered.hbm := CreateDIBSection(Window_W,Window_H)
	Layered.hdc := CreateCompatibleDC()
	Layered.obm := SelectObject(Layered.hdc,Layered.hbm)
	Layered.G := Gdip_GraphicsFromHDC(Layered.hdc)
	Gdip_SetSmoothingMode(Layered.G,Smoothing)
	return Layered
}
Create_Layered_GUI(Layered){
	Gui,% Layered.Name ": +E0x80000 +LastFound " Layered.Options 
	Gui,% Layered.Name ":Show",% "x" Layered.X " y" Layered.Y " w" Layered.W " h" Layered.H " NA"
}	
Layered_Window_ShutDown(This){
	SelectObject(This.hdc,This.obm)
	DeleteObject(This.hbm)
	DeleteDC(This.hdc)
	gdip_deleteGraphics(This.g)
	Gdip_Shutdown(This.Token)
}
New_Brush(colour:="000000",Alpha:="FF"){
	new_colour := "0x" Alpha colour 
	return Gdip_BrushCreateSolid(new_colour)
}
New_Pen(colour:="000000",Alpha:="FF",Width:= 5){
	new_colour := "0x" Alpha colour 
	return Gdip_CreatePen(New_Colour,Width)
}	
	
Temp (1).gif
Temp (1).gif (127.38 KiB) Viewed 1903 times
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

14 Jul 2021, 02:36

Wow, very nice @Hellbent, your rotary knob has that modern and simple look.
unfortunately, I was not able to test it because I'm still on Windows 7, lol :)
But I am a big fan of your controls... they usually work on windows 7.
Can this knob above be modified to work on win7?
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

14 Jul 2021, 12:13

keylo wrote:
14 Jul 2021, 02:36
Wow, very nice @Hellbent, your rotary knob has that modern and simple look.
unfortunately, I was not able to test it because I'm still on Windows 7, lol :)
But I am a big fan of your controls... they usually work on windows 7.
Can this knob above be modified to work on win7?
Thank you.

This should work for windows 7+ ( likely older versions too ) ?

Just replace the path to the GDIP lib , run, and you should see this.

.
Temp (1).gif
Temp (1).gif (107.41 KiB) Viewed 1833 times

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
;***************************************************************************************************
;***************************************************************************************************

#SingleInstance, Force
SetBatchLines, -1
Coordmode, Mouse, Client

Pi := 3.14159265359
size := 84 
Val := 5
Output := 1

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

Gui, 1:New, +AlwaysOnTop -DPIScale 
Gui, 1:Color, % BackgroundColor := "22262A" , 222930
Gui, 1:Margin, 30, 30 

Gui, 1:Add, Text, xm ym w%size% h%size% 0xE BackgroundTrans hwndhwnd gUpdateDial,

Gui, 1:Show,, Dial Control

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

GDIP_StartUp()
DrawGraphics( hwnd , Val , Output , "0xFF" BackgroundColor )

return
;********************************************************************************************************
;********************************************************************************************************

GuiClose:
GuiContextMenu:
*ESC::ExitApp

;*************************************************************************************************************************************************************************	
;*************************************************************************************************************************************************************************	
;*************************************************************************************************************************************************************************	
UpdateDial:
	While( GetKeyState( "LButton" ) ){
		MouseGetPos, tx , ty
		x := tx - ( 42 + 30 ) , y := ty - ( 42 + 30 ) ;Half the width of the control (center) + the starting position (the margin) of the control
		Angle := dllcall( "msvcrt\atan2" , "Double" , y , "Double" , x , "CDECL Double" ) * 180 / Pi * -1 
		Val := ( Angle - 180 ) * -1 
		( Val > 315 ) ? ( Val := 0 ) : ( ( Val > 270 ) ? ( Val := 270 ) )
		Output := Round( Val / 270 * 100 )
		DrawGraphics( hwnd , Val , Output )
		Sleep,30
	}
	;SoundSet, % Output 
	return
;*************************************************************************************************************************************************************************	
;*************************************************************************************************************************************************************************	
;*************************************************************************************************************************************************************************	

DrawGraphics( hwnd , Val := 5 , output := 1, BackgroundColor := "" ){
	;Bitmap Created Using: HB Bitmap Maker
	;Dial Control: July 14th, 2021
	local pBitmap, hBitmap, G, Pen, Brush 
	static BGC 
	( BGC = "" && BackgroundColor = "" ) ? ( BGC := "0xFFFFFFFF" ) : ( ( BackgroundColor != "" ) ? ( BGC := BackgroundColor ) )
	pBitmap := Gdip_CreateBitmap( 84 , 84 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 4 )
	Brush := Gdip_BrushCreateSolid( BGC ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 88 , 88 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777700" ) , Gdip_FillEllipse( G , Brush , 2 , 2 , 80 , 80 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF111111" ) , Gdip_FillEllipse( G , Brush , 4 , 4 , 76 , 76 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF881111" , 7 ) , Gdip_DrawArc( G , Pen , 7 , 7 , 70 , 70 , 180 , 360 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF881111" , 7 ) , Gdip_DrawArc( G , Pen , 12 , 12 , 60 , 60 , 180 , -90 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF777700" , 5 ) , Gdip_DrawArc( G , Pen , 12 , 12 , 60 , 60 , 180 , Val ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF881111" ) , Gdip_FillEllipse( G , Brush , 14 , 14 , 56 , 56 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF777700" ) , Gdip_TextToGraphics( G , output , "s20 Center vCenter Bold c" Brush " x13 y14" , "Segoe ui" , 56 , 56 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , output , "s20 Center vCenter Bold c" Brush " x15 y16" , "Segoe ui" , 56 , 56 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFFFFF00" ) , Gdip_TextToGraphics( G , output , "s20 Center vCenter Bold c" Brush " x14 y15" , "Segoe ui" , 56 , 56 ) , Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
	Gdip_DisposeImage( pBitmap )
	SetImage( hwnd , hBitmap )
	DeleteObject( hBitmap )
}
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

14 Jul 2021, 13:21

Wow, thank you @Hellbent, exactly what I needed . :bravo:
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

14 Jul 2021, 15:06

@keylo

I have made a very simple class for that dial control design ( was / is still just a rough prototype / mockup ).

You can change many of the dials properties as you create it. See the class Method [ _SetDefaults() ] to see what you can change.
You don't need to set the value of anything that is using the defaults and you can edit the defaults to anything.

Here is the class:

Code: Select all

;			Dial Class
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
class DialControl	{
	;Dial Control: July 14th, 2021
	__New( obj := "" ){
		This._SetDefaults()
		This._UpdateDefaults( obj )
		This._CreateTrigger()
		This._DrawGraphics()
	}
	_SetDefaults(){
		This.GuiName := "1"
		This.X := 10
		This.Y := 10
		This.Size := 50
		This.Value := 1
		This.SweepValue := 5
		This.BackgroundColor := "0xFFFFFFFF"
		This.MainColor := "0xFF62666a"
		This.GaugeLineColor := "0xFF21F38F"
		This.GaugeLineBackgroundColor := "0xFF000000"
		This.BorderColor := "0xFF92969a"
		This.TextColor := "0xFF00FFFF"
		This.TextColorTop := "0xFF92969a"
		This.TextColorBottom := "0xFF000000"
		This.Font := "Segoe Ui"
		This.FontSize := "16"
		This.Range := 50
	}
	_UpdateDefaults( obj := "" ){
		local k, v 
		for k, v in obj
			This[k] := v
	}
	_CreateTrigger(){
		local hwnd , bd
		Gui , % This.GuiName ":Add" , Text , % "x" This.X " y" This.Y " w" This.Size " h" This.Size " hwndhwnd 0xE BackgroundTrans"  
		bd := This._UpdateDial.Bind( This )
		This.Hwnd := hwnd
		GuiControl, % This.GuiName ":+G" , % hwnd , % bd 
	}
	_UpdateDial(){
		local tx, ty, x, y , angle , pi := 3.14159265359
		CoordMode, Mouse, Client
		While( GetKeyState( "LButton" ) ){
			MouseGetPos, tx , ty
			x := tx - ( This.Size / 2 + This.X ) 
			y := ty - ( This.Size / 2 + This.Y ) 
			angle := dllcall( "msvcrt\atan2" , "Double" , y , "Double" , x , "CDECL Double" ) * 180 / Pi * -1 
			This.SweepValue := ( angle - 180 ) * -1 
			( This.SweepValue > 315 ) ? ( This.SweepValue := 0 ) : ( ( This.SweepValue > 270 ) ? ( This.SweepValue := 270 ) )
			This.Value := Round( This.SweepValue / 270 * This.Range )
			This._DrawGraphics()
			Sleep,30
		}
		if( This.Label ){
			Try	{
				gosub, % This.Label
			}
		}
	}
	_DrawGraphics(){
		;Bitmap Created Using: HB Bitmap Maker
		local pBitmap, hBitmap, G, Pen, Brush 
		pBitmap := Gdip_CreateBitmap( This.Size , This.Size ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -2 , -2 , This.Size + 4 , This.Size + 4 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.BorderColor ) , Gdip_FillEllipse( G , Brush , 2 , 2 , This.Size - 4 , This.Size - 4 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.GaugeLineBackgroundColor ) , Gdip_FillEllipse( G , Brush , 4 , 4 , This.Size - 8 , This.Size - 8 ) , Gdip_DeleteBrush( Brush )
		Pen := Gdip_CreatePen( This.MainColor , 7 ) , Gdip_DrawArc( G , Pen , 7 , 7 , This.Size - 14 , This.Size - 14 , 180 , 360 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( This.MainColor , 7 ) , Gdip_DrawArc( G , Pen , 12 , 12 , This.Size - 24 , This.Size - 24 , 180 , -90 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( This.GaugeLineColor , 5 ) , Gdip_DrawArc( G , Pen , 12 , 12 , This.Size - 24 , This.Size - 24 , 180 , This.SweepValue ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillEllipse( G , Brush , 14 , 14 , This.Size - 28 , This.Size - 28 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( This.TextColorTop ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x13 y14" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.TextColorBottom ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x15 y16" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.TextColor ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x14 y15" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
		SetImage( This.hwnd , hBitmap )
		DeleteObject( hBitmap )
	}
}
And here is a little demo of it:

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
#Include <DialControl Class> ;<<<<<------
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
GDIP_StartUp()

Gui, 1:New, +AlwaysOnTop -DPIScale 
Gui, 1:Color, % BackgroundColor := "22262A" , 222930
Gui, 1:Margin, 30, 30 

MyDial := New DialControl( { Range: 9 , X: 20 , Y: 30 , Size: 60 , BackgroundColor: "0xFF22262a" , FontSize: 12 , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" , GaugeLineColor: "0xFFFF0000" , Font: "webdings" } )
MyDial2 := New DialControl( { Range: 5350 , X: 20 , Y: 100 , Size: 70 , BackgroundColor: "0xFF22262a" , FontSize: 12 , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" } )
SoundDial := New DialControl( { Label: "SetSoundLevel" , GaugeLineBackgroundColor: "0xFFFFFFFF" ,  GaugeLineColor: "0xFFD008C4" , Range: 100 , X: 20 , Y: 180 , Size: 90 , BackgroundColor: "0xFF22262a" , FontSize: 16 , MainColor: "0xFF31F2CE" , BorderColor: "0x99D008C4" , TextColor: "0xFF000000" , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" } )
Dial4 := New DialControl( { GaugeLineColor: "0xFF888800" , Range: 250 , X: 20 , Y: 280 , Size: 120 , TextColor: "0xFFFFFF00" , BackgroundColor: "0xFF22262a" , FontSize: 36 , MainColor: "0xFF02060A" , BorderColor: "0x99888800" } )

Gui, 1:Show,, Dial Control

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

SetSoundLevel:
	MsgBox, 262144,, % SoundDial.Value
	;~ SoundSet, % SoundDial.Value
	return
Temp (1).gif
Temp (1).gif (119.63 KiB) Viewed 1793 times
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

14 Jul 2021, 16:08

lol :) I was thinking to myself that it would be nice if it was a class. I came here and you've done it, Thank you
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

15 Jul 2021, 01:37

@keylo

I have done a pass at the graphics for the dial control in my Bitmap Maker script
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62550

.
20210715014055.png
20210715014055.png (103.81 KiB) Viewed 1753 times
I'm not sure if I will code them in or not, but here are the graphics for them ( 3 color themes )

It should be easy enough to adapt the class to use these graphics, with the exception of the small circle (If you can't figure out how to code it you can remove it)

Here are the graphics in a small demo window.

Code: Select all

;***************************************************************************************************
#Include <My Altered Gdip Lib>   ;Replace with your path to the Gdip.ahk lib
;***************************************************************************************************
;#Include <PopUpWindow Class> ;I have included this class at the bottom of the script
;***************************************************************************************************
#SingleInstance force
#NoEnv
SetBatchLines, -1
GDIP_StartUp()

Gui1 := New PopUpWindow( { WindowName: "1" , WindowOptions: " -DPIScale +AlwaysOnTop " , WindowSmoothing: 2 , X: A_ScreenWidth / 2 - ( w := 5 * 90 ) / 2 , Y: 100 , W: w + 20, H: 166 } )
Gui1.ShowWindow( "Dial Design 2" )

Gui1.PaintBackground( "0xFF22262a" )
Gui1.DrawBitmap( BlueDial() , { X: x := 90 , Y: 20 , W: w := 90 , H: h := 126 } , dispose := 1 )
Gui1.DrawBitmap( GreenDial() , { X: x += w + 10 , Y: 20 , W: w , H: h } , dispose := 1 )
Gui1.DrawBitmap( RedDial() , { X: x += w + 10 , Y: 20 , W: w , H: h } , dispose := 1 )
Gui1.UpdateWindow()

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

Numpad3::
	PopUpWindow.Helper()
	return
	
BlueDial(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 90 , 126 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF22262a" ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 94 , 134 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 25 , 45 , 55 , 74 , "0xFFF0F0F0" , "0xFF000000" , 1 ) , Gdip_FillEllipse( G , Brush , 21 , 41 , 48 , 48 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 17 , 44 , 52 , 40 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 22 , 42 , 46 , 46 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 28 , 46 , 35 , 30 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 26 , 46 , 38 , 38 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF000000" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 270 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF3399FF" , 2 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 135 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 35 , 58 , 19 , 17 , "0xFF000000" , "0x663399FF" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 37 , 58 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 37 , 60 , 17 , 10 , "0xFF3399FF" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 37 , 58 , 16 , 16 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 33 , 48 , 24 , 20 , "0x44999999" , "0x00000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 33 , 52 , 22 , 10 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , 62 , 40 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 23 , 97 , 47 , 15 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 12 , 95 , 25 , 75 , "0xFF3399FF" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x20 y95" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x22 y97" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x21 y96" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 10 , 8 , 71 , 18 , "0x553399FF" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 9 , 5 , 71 , 39 , "0x99000000" , "0xaaF0F0F0" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x11F0F0F0" , 5 ) , Gdip_DrawLine( G , Pen , 14 , 10 , 76 , 9 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x9 y5" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x11 y7" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFa2c6ff" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x10 y6" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 3 , 3 , 84 , 64 , "0xFF3399FF" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrush( 0 , 115 , 88 , 66 , "0xFF3399FF" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

GreenDial(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 90 , 126 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF22262a" ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 94 , 134 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 25 , 45 , 55 , 74 , "0xFFF0F0F0" , "0xFF000000" , 1 ) , Gdip_FillEllipse( G , Brush , 21 , 41 , 48 , 48 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 17 , 44 , 52 , 40 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 22 , 42 , 46 , 46 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 28 , 46 , 35 , 30 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 26 , 46 , 38 , 38 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF000000" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 270 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF00ff00" , 2 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 135 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 35 , 58 , 19 , 17 , "0xFF000000" , "0x6600ff00" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 37 , 58 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 37 , 60 , 17 , 10 , "0xFF00ff00" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 37 , 58 , 16 , 16 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 33 , 48 , 24 , 20 , "0x44999999" , "0x00000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 33 , 52 , 22 , 10 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF00ff00" ) , Gdip_FillEllipse( G , Brush , 62 , 40 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 23 , 97 , 47 , 15 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 12 , 95 , 25 , 75 , "0xFF00ff00" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x20 y95" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x22 y97" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF00ff00" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x21 y96" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 10 , 8 , 71 , 18 , "0x5500ff00" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 9 , 5 , 71 , 39 , "0x99000000" , "0xaaF0F0F0" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x11F0F0F0" , 5 ) , Gdip_DrawLine( G , Pen , 14 , 10 , 76 , 9 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x9 y5" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x11 y7" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFa2ffa2" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x10 y6" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 3 , 3 , 84 , 64 , "0xFF00ff00" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrush( 0 , 115 , 88 , 66 , "0xFF00ff00" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

RedDial(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 90 , 126 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF22262a" ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 94 , 134 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 25 , 45 , 55 , 74 , "0xFFF0F0F0" , "0xFF000000" , 1 ) , Gdip_FillEllipse( G , Brush , 21 , 41 , 48 , 48 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 17 , 44 , 52 , 40 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 22 , 42 , 46 , 46 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 28 , 46 , 35 , 30 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 26 , 46 , 38 , 38 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF000000" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 270 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFFff0000" , 2 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 135 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 35 , 58 , 19 , 17 , "0xFF000000" , "0x66ff0000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 37 , 58 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 37 , 60 , 17 , 10 , "0xFFff0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 37 , 58 , 16 , 16 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 33 , 48 , 24 , 20 , "0x44999999" , "0x00000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 33 , 52 , 22 , 10 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFff0000" ) , Gdip_FillEllipse( G , Brush , 62 , 40 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 23 , 97 , 47 , 15 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrush( 12 , 95 , 25 , 75 , "0xFFff0000" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 20 , 95 , 50 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x20 y95" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x22 y97" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFff0000" ) , Gdip_TextToGraphics( G , "12345" , "s14 Center vCenter bold c" Brush " x21 y96" , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 10 , 8 , 71 , 18 , "0x55ff0000" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 9 , 5 , 71 , 39 , "0x99000000" , "0xaaF0F0F0" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0x11F0F0F0" , 5 ) , Gdip_DrawLine( G , Pen , 14 , 10 , 76 , 9 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x9 y5" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x11 y7" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFffc6a2" ) , Gdip_TextToGraphics( G , "Master" , "s12 Center vCenter Bold c" Brush " x10 y6" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 3 , 3 , 84 , 64 , "0xFFff0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrush( 0 , 115 , 88 , 66 , "0xFFff0000" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}



;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;Layered Window Class
class PopUpWindow	{
	;Class By: Hellbent
	;Apr 2021
	static Index := 0 , Windows := [] , Handles := [] , HelpHandles := [] , HelperEditHwnd
	__New( obj := "" ){
		This._SetDefaults( )
		if( isObject( obj ) )
			This.SetWindowProperties( obj )
		This._SetupWindowGraphics()
		
	}
	_SetDefaults(){
		PopUpWindow.Index++
		This.WindowName := "HBLayeredWindow" PopUpWindow.Index
		This.WindowSmoothing := 2
		This.WindowOptions := " -DPIScale +AlwaysOnTop "
		This.X := 10
		This.Y := 10
		This.W := 10
		This.H := 10
		
		
		
	}
	PaintBackground( color := "0xFF000000" ){
		Brush := Gdip_BrushCreateSolid( color ) 
		Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 ) 
		Gdip_DeleteBrush( Brush )
	}
	_SetupWindowGraphics(){
		This.Hwnd := This._CreateGUI()
		This.hbm := CreateDIBSection( This.W , This.H )
		This.hdc := CreateCompatibleDC()
		This.obm := SelectObject( This.hdc , This.hbm )
		This.G := Gdip_GraphicsFromHDC( This.hdc )
		Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )
		PopUpWindow.Handles[ This.Hwnd ] := PopUpWindow.Index
		PopUpWindow.Windows[ PopUpWindow.Index ] := This
		
	}
	SetWindowProperties( obj , updateG := 0 ){
		local k , v 
		for k , v in obj
			if( k != "hwnd" )
				This[k] := v
			
			
		if(updateG){	
			SelectObject( This.hdc , This.obm )
			DeleteObject( This.hbm )
			DeleteDC( This.hdc )
			
			This.hbm := CreateDIBSection( This.W , This.H )
			This.hdc := CreateCompatibleDC()
			This.obm := SelectObject( This.hdc , This.hbm )
			This.G := Gdip_GraphicsFromHDC( This.hdc )
			Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )	
		}
	}
	ShowWindow( Title := "" ){
		Gui , % This.WindowName ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
	}
	HideWindow(){
		Gui , % This.WindowName ":Hide",
	}
	UpdateWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
		;~ UpdateLayeredWindow( This.hwnd , This.hdc  )
	}
	ClearWindow(){
		Gdip_GraphicsClear( This.G )
	}
	DrawBitmap( pBitmap , obj := "" , dispose := 1 ){
		(!IsObject(obj))?(obj := {})
		(!obj.HasKey("X"))?(obj.X:=0)
		(!obj.HasKey("Y"))?(obj.Y:=0)
		(!obj.HasKey("W"))?(obj.W:=This.W)
		(!obj.HasKey("H"))?(obj.H:=This.H)
		Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
		if( dispose )
			Gdip_DisposeImage( pBitmap )
	}
	DeleteWindow(){
		Gui, % This.WindowName ":Destroy"
		SelectObject( This.hdc , This.obm )
		DeleteObject( This.hbm )
		DeleteDC( This.hdc )
		Gdip_DeleteGraphics( This.G )
		hwnd := This.Hwnd
		for k, v in PopUpWindow.Windows[ Hwnd ]
			This[k] := ""
		PopUpWindow.Windows[ Hwnd ] := ""
	}
	_CreateGUI(){
		local hwnd
		Gui , % This.WindowName ":New" , % " +E0x80000 hwndhwnd -Caption  " This.WindowOptions
		return hwnd
	}
	Helper(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local hwnd, bd
		
		
		Gui, HBLWHelperGui:New, +AlwaysOnTop 
		Gui, HBLWHelperGui:Color, 62666a, 24282c
		Gui, HBLWHelperGui:Font, cWhite s10 , Segoe UI
		Gui, HBLWHelperGui:Margin, 5 , 5
		
		Gui, HBLWHelperGui:Add, Edit, xm ym w200 r1 Center hwndHwnd, Gui1
		PopUpWindow.HelperEditHwnd := Hwnd
		Gui, HBLWHelperGui:Margin, 5 , 1
		Loop, % List.Length()	{
		
			Gui, HBLWHelperGui:Add, Button, xm wp h23 -Theme hwndhwnd, % List[ A_Index ]
			PopUpWindow.HelpHandles[hwnd] := List[ A_Index ]
			bd := PopUpWindow._ClipIt.Bind( PopUpWindow )
			GuiControl , HBLWHelperGui: +G , % Hwnd , % bd
		}
		
		Gui, HBLWHelperGui:Show, 
		
	}
	_ClipIt(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local Output , FQ := 400
		GuiControlGet, Output , HBLWHelperGui: , % PopUpWindow.HelperEditHwnd
		Switch A_GuiControl
		{
			case List[1]:
				Clipboard := Output " := New PopUpWindow( { WindowName: ""1"" , WindowOptions: "" -DPIScale +AlwaysOnTop "" , WindowSmoothing: 2 , X: ""Center"" , Y: ""Center"" , W: 100 , H: 100 } )"
				loop 2
					SoundBeep, FQ
				return
			case List[2]:
				Clipboard := Output ".SetWindowProperties( { X: """" , Y: """" , W: """" , H: """" } )"
				loop 2
					SoundBeep, FQ
				return
			case List[3]:
				Clipboard := Output ".ShowWindow( MyWindowTitle := """" )"
				loop 2
					SoundBeep, FQ
				return
			case List[4]:
				Clipboard := Output ".HideWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[5]:
				Clipboard := Output ".UpdateWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[6]:
				Clipboard := Output ".ClearWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[7]:
				Clipboard := Output ".DrawBitmap( pBitmap := """" , { X: """" , Y: """" , W: """" , H: """" } , dispose := 1 )"
				loop 2
					SoundBeep, FQ
				return
			case List[8]:
				Clipboard := Output ".PaintBackground( color := ""0xFF000000"" )"
				loop 2
					SoundBeep, FQ
				return
			case List[9]:
				Clipboard := Output ".DeleteWindow()"
				loop 2
					SoundBeep, FQ
				return
			Default:
				ToolTip, Looks like a new case needs to be added
				return
			
		}
	}
}
;**************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************
20210715021512.png
20210715021512.png (27.59 KiB) Viewed 1753 times
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Rotary knob

15 Jul 2021, 02:18

really outstanding work @Hellbent and by the way loved that video with you @Joe Glines and raptor, learned a lot especially how much I don't know :lolno:

:thumbup:
keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

15 Jul 2021, 09:35

Not so long ago, I would laugh if someone tells me those types of controls could be done in AHK, now there it is. Thanks @Hellbent :thumbup:
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

15 Jul 2021, 12:18

AHKStudent wrote:
15 Jul 2021, 02:18
really outstanding work @Hellbent and by the way loved that video with you @Joe Glines and raptor, learned a lot especially how much I don't know :lolno:

:thumbup:
:thumbup:
Thanks. The only thing I know is that I know nothing lol.
keylo wrote:
15 Jul 2021, 09:35
Not so long ago, I would laugh if someone tells me those types of controls could be done in AHK, now there it is. Thanks @Hellbent :thumbup:
NP. As soon as I can get myself a working custom edit control the lid comes off and any kind of control design becomes possible!!
if you have any insights I would love to hear them.


Custom Edit Control topic.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92270
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Rotary knob

17 Jul 2021, 02:56

I got it wired up and played around with making it so that you can choose which parts of the graphics get shown ( the border for example ) .

Temp (1).gif
Temp (1).gif (169.56 KiB) Viewed 1672 times
20210716114613.png
20210716114613.png (82.45 KiB) Viewed 1672 times
20210717022627.png
20210717022627.png (44.24 KiB) Viewed 1672 times
still needs a bit of polish.

Code: Select all


;			Dial Class 2
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
class DialControl	{
	;Dial Control: July 17th, 2021
	__New( obj := "" ){
		This._SetDefaults()
		This._UpdateDefaults( obj )
		This._CreateTrigger()
		This._DrawGraphics()
	}
	_SetDefaults(){
		This.GuiName := "1"
		This.X := 10
		This.Y := 10
		This.Width := 90 	;<<<<<<----------  Don't change
		This.Height := 126 	;<<<<<<----------  Don't change
		This.Range := 30
		This.Value := 1
		This.SweepValue := 5
		This.Header := "Dial"
		This.BackgroundColor := "0xFFFFFFFF"
		This.MainColor := "0xFF62666a"
		This.Font := "Segoe Ui"
		This.FontSize := "16"
		This.WantBorder := 1
		This.WantDot := 1
		This.WantLetters := 0
		This.WantHeader := 1
		This.LowerText := 0
		This.Target := ""
		This.Dot := New HB_Vector(13,65)
	}
	_UpdateDefaults( obj := "" ){
		local k, v 
		for k, v in obj
			This[ k ] := v
		This.Center := New HB_Vector( 45 , 65 )
		This.Point := New HB_Vector( This.X + 45 , This.Y + 65 )
		( This.WantLetters && This.Letters := ["A","B","C","D","E","F"] )
			
		
	}
	_CreateTrigger(){
		local hwnd , bd
		Gui , % This.GuiName ":Add" , Text , % "x" This.X " y" This.Y " w" This.Width " h" This.Height " hwndhwnd 0xE BackgroundTrans"  
		bd := This._UpdateDial.Bind( This )
		This.Hwnd := hwnd
		GuiControl, % This.GuiName ":+G" , % hwnd , % bd 
	}
	_UpdateDial(){
		local tx, ty, x, y , angle , pi := 3.14159265359 , Max := 200
		CoordMode, Mouse, Client
		MouseGetPos, tx , ty
		This.Pos := New HB_Vector( tx - This.X , ty - This.Y )
		if( This.Pos.Dist( This.Center ) > 35 ){
			;~ SoundBeep,500
			return
		}
		While( GetKeyState( "LButton" ) ){
			MouseGetPos, tx , ty
		
			
			;~ x := tx - ( This.Size / 2 + This.X ) 
			;~ x := tx - ( This.Center.X ) 
			x := tx - ( This.Point.X ) 
			;~ y := ty - ( This.Size / 2 + This.Y ) 
			;~ y := ty - (  This.Center.Y ) 
			y := ty - (  This.Point.Y ) 
			angle := dllcall( "msvcrt\atan2" , "Double" , y , "Double" , x , "CDECL Double" ) * 180 / Pi * -1 
			This.SweepValue := ( angle - 180 ) * -1 
			This.Finder := This.SweepValue
			;~ ( This.SweepValue > 315 ) ? ( This.SweepValue := 0 ) : ( ( This.SweepValue > 270 ) ? ( This.SweepValue := 270 ) )
			( This.SweepValue > 315 ) ? ( This.SweepValue := 0 ) : ( ( This.SweepValue > Max ) ? ( This.SweepValue := Max ) )
			;~ This.Value := Round( This.SweepValue / 270 * This.Range )
			This.Value := Round( This.SweepValue / Max * This.Range )
			;~ if( ( angle - 180 ) * -1  >= 0 &&  ( angle - 180 ) * -1  <= 270 ){
			;~ ToolTip, % This.SweepValue "`nFinder: " This.Finder
			;~ if( ( ( angle - 180 ) * -1 ) >= 0 && ( ( angle - 180 ) * -1 )  <= Max ){
				This.Dot := New HB_Vector( This.Center.X , This.Center.Y )
				;~ This.Target := New HB_Vector( tx - This.X , ty - This.Y )
				This.Target := New HB_Vector( tx - This.X, ty - This.Y )
				;~ This.Target := New HB_Vector( tx , ty  )
				This.Vol := New HB_Vector( This.Target.X , This.Target.Y )
				This.Vol.Sub(This.Center)
				This.Vol.SetMag(32)
				This.Dot.Add( This.Vol )
				if( This.Finder >= Max && This.Finder <= 315 ){
					This.Dot.X := 75
					This.Dot.Y := 76
				}else if( This.Finder >= 315 ){
					;~ SoundBeep, 500
					This.Dot.X := 13
					This.Dot.Y := 65
					
				}
			;~ }
			This._DrawGraphics()
			Sleep,30
		}
		if( This.Label ){
			Try	{
				gosub, % This.Label
			}
		}
	}
	_DrawGraphics(){
		;Bitmap Created Using: HB Bitmap Maker
		local pBitmap, hBitmap, G, Pen, Brush, tx, ty ;90 126
		pBitmap := Gdip_CreateBitmap( 90 , 126 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 94 , 130 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrush( 21 , 41 , 48 , 48 , "0xFFF0F0F0" , "0xFF000000" , 1 ) , Gdip_FillEllipse( G , Brush , 21 , 41 , 48 , 48 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 17 , 44 , 52 , 40 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 22 , 42 , 46 , 46 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_CreateLineBrushFromRect( 28 , 46 , 35 , 30 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 26 , 46 , 38 , 38 ) , Gdip_DeleteBrush( Brush )
		;~ Pen := Gdip_CreatePen( "0xFF000000" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 270 ) , Gdip_DeletePen( Pen )
		;~ Pen := Gdip_CreatePen( "0xFF000000" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 200 ) , Gdip_DeletePen( Pen )
		;~ Pen := Gdip_CreatePen( "0xFF224466" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 200 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( "0xFF224466" , 3 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , 200 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( "0xFF3399FF" , 2 ) , Gdip_DrawArc( G , Pen , 30 , 50 , 30 , 30 , 180 , This.SweepValue ) , Gdip_DeletePen( Pen )
		Brush := Gdip_CreateLineBrushFromRect( 35 , 58 , 19 , 17 , "0xFF000000" , "0x663399FF" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 37 , 58 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 37 , 60 , 17 , 10 , "0xFF3399FF" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 37 , 58 , 16 , 16 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_CreateLineBrushFromRect( 33 , 48 , 24 , 20 , "0x44999999" , "0x00000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 33 , 52 , 22 , 10 ) , Gdip_DeleteBrush( Brush )
		;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , 62 , 40 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
		if( This.WantDot )
		Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , This.Dot.X - 2 , This.Dot.Y - 2 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
		;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , This.Center.X - 2 , This.Center.Y - 2 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
		ty := 95
		if( This.LowerText )
			ty := 105
		;~ Brush := Gdip_CreateLineBrushFromRect( 23 , ty , 50 , 25 , "0xFF333333" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 , ty , 50 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
		;~ Brush := Gdip_CreateLineBrush( 12 , ty , 25 , 75 , "0xFF3399FF" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 20 , ty , 50 , 20 , 5 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Value , "s16 Center vCenter bold c" Brush " x20 y" ty , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Value , "s16 Center vCenter bold c" Brush " x22 y" ty + 2 , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFFf0f0f0" ) , Gdip_TextToGraphics( G , This.Value , "s16 Center vCenter bold c" Brush " x21 y" ty + 1 , "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
		
		if( This.WantHeader ){
			Brush := Gdip_CreateLineBrushFromRect( 10 , 8 , 71 , 18 , "0x553399FF" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_CreateLineBrushFromRect( 9 , 5 , 71 , 39 , "0x99000000" , "0xaaF0F0F0" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 10 , 5 , 70 , 20 , 5 ) , Gdip_DeletePen( Pen )
			Pen := Gdip_CreatePen( "0x11F0F0F0" , 5 ) , Gdip_DrawLine( G , Pen , 14 , 10 , 76 , 9 ) , Gdip_DeletePen( Pen )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Header , "s12 Center vCenter Bold c" Brush " x9 y5" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Header , "s12 Center vCenter Bold c" Brush " x11 y7" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_BrushCreateSolid( "0xFFa2c6ff" ) , Gdip_TextToGraphics( G , This.Header , "s12 Center vCenter Bold c" Brush " x10 y6" , "Segoe ui" , 70 , 20 ) , Gdip_DeleteBrush( Brush )
		}
		if( This.WantBorder ){	
			Brush := Gdip_CreateLineBrushFromRect( 3 , 3 , 84 , 64 , "0xFF3399FF" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
			Brush := Gdip_CreateLineBrush( 0 , 115 , 88 , 66 , "0xFF3399FF" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 85 , 120 , 5 ) , Gdip_DeletePen( Pen )
		}
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
		SetImage( This.hwnd , hBitmap )
		DeleteObject( hBitmap )
	}
}

keylo
Posts: 52
Joined: 21 Oct 2020, 21:03

Re: Rotary knob

17 Jul 2021, 18:53

Verry nice Hellbent,
I did modified your previous DialControl to respond to mouse up/down instead of rotate , it works good but I'm not sure if it is the right way to do it.
It would be nice if (mouse up/down instead of rotate) could be added as option in you latest dialcontrol.

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
;~ #Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
;~ #Include <DialControl Class> ;<<<<<------

;~ https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92621
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
GDIP_StartUp()

Gui, 1:New, +AlwaysOnTop -DPIScale 
Gui, 1:Color, % BackgroundColor := "22262A" , 222930
Gui, 1:Margin, 30, 30 

MyDial := New DialControl( { Range: 9 , X: 20 , Y: 30 , Size: 60 , BackgroundColor: "0xFF22262a" , FontSize: 12 , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" , GaugeLineColor: "0xFFFF0000" , Font: "webdings" } )
MyDial2 := New DialControl( { Range: 5350 , X: 20 , Y: 100 , Size: 70 , BackgroundColor: "0xFF22262a" , FontSize: 12 , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" } )
SoundDial := New DialControl( { Label: "SetSoundLevel" , GaugeLineBackgroundColor: "0xFF22262a" ,  GaugeLineColor: "0xFFFF0000" , Range: 1000 , X: 20 , Y: 180 , Size: 90 , BackgroundColor: "0xFF22262a" , FontSize: 16 , MainColor: "0xFF606321" , BorderColor: "0x99888800" , TextColor: "0xFFFFFF2f" , TextColorTop: "0x00000000" , TextColorBottom: "0x00000000" ,value : "200" , SweepValue : 40  } )
Dial4 := New DialControl( { GaugeLineColor: "0xFF888800" , Range: 250 , X: 20 , Y: 280 , Size: 120 , TextColor: "0xFFFFFF00" , BackgroundColor: "0xFF22262a" , FontSize: 36 , MainColor: "0xFF02060A" , BorderColor: "0x99888800" } )

Gui, 1:Show,, Dial Control


return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

SetSoundLevel:
	;~ MsgBox, 262144,, % SoundDial.Value
	;~ ToolTip, % SoundDial.Value
	;~ SoundSet, % SoundDial.Value
	return

q::
NewValue :=  500
 MyRange := SoundDial.range
SoundDial.value :=  NewValue
SoundDial.SweepValue := round((269/MyRange)*NewValue)
SoundDial._DrawGraphics() 
return

w::
SoundDial.set(800)
return











;			Dial Class
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
;*************************************************************************************************************************************************************************************
class DialControl	{
	;Dial Control: July 14th, 2021
	__New( obj := "" ){
		This._SetDefaults()
		This._UpdateDefaults( obj )
		This._CreateTrigger()
		This._DrawGraphics()
	}
         Set(NewValue)   ; wow I did that
         {
         This.value :=  NewValue
         This.SweepValue := round((269/This.range)*NewValue)
         This._DrawGraphics() 
         }

	_SetDefaults(){
		This.GuiName := "1"
		This.X := 10
		This.Y := 10
		This.Size := 50
        This.Range := 50
		This.Value := 1
		This.SweepValue :=  5
		This.BackgroundColor := "0xFFFFFFFF"
		This.MainColor := "0xFF62666a"
		This.GaugeLineColor := "0xFF21F38F"
		This.GaugeLineBackgroundColor := "0xFF000000"
		This.BorderColor := "0xFF92969a"
		This.TextColor := "0xFF00FFFF"
		This.TextColorTop := "0xFF92969a"
		This.TextColorBottom := "0xFF000000"
		This.Font := "Segoe Ui"
		This.FontSize := "16"
		
	}
	_UpdateDefaults( obj := "" ){
		local k, v 
		for k, v in obj
			This[k] := v
	}
	_CreateTrigger(){
		local hwnd , bd
		Gui , % This.GuiName ":Add" , Text , % "x" This.X " y" This.Y " w" This.Size " h" This.Size " hwndhwnd 0xE BackgroundTrans "  
		bd := This._UpdateDial.Bind( This )
		This.Hwnd := hwnd
		GuiControl, % This.GuiName ":+G" , % hwnd , % bd 
	}
	_UpdateDial(){
		local tx, ty, x, y , angle , pi := 3.14159265359 
        
        ;~ ******mouse up/down instead of rotate *****************
		mul := round(0.002*This.Range)  ; so if the range is big you don't have to move the mouse too far
		CoordMode, Mouse, Client
            MouseGetPos,, startY ;##
            startY := startY + (startY * mul ) ;  * mul so if the range is big you don't have to move the mouse too far
            StartVal := this.Value
            While( GetKeyState( "LButton" ) ){
         MouseGetPos,, currentY
         currentY := currentY + (currentY * mul )
         Val := startY-currentY +StartVal  ;startAngle
         max := This.Range  

               TextOutput := val  ; 
               TextOutput := TextOutput>max ? max : TextOutput<0 ? 0: TextOutput 
               val := val>max ? max : val<0 ? 0: val 
               val := round((269/max)*val)
		;~ ***********************
		
		/*  original from hellbent you have to rotate instead of up down with the mouse
		;~ MouseGetPos, tx , ty
			x := tx - ( This.Size / 2 + This.X ) 
			y := ty - ( This.Size / 2 + This.Y ) 
			angle := dllcall( "msvcrt\atan2" , "Double" , y , "Double" , x , "CDECL Double" ) * 180 / Pi * -1 
			This.SweepValue := ( angle - 180 ) * -1 
			( This.SweepValue > 315 ) ? ( This.SweepValue := 0 ) : ( ( This.SweepValue > 270 ) ? ( This.SweepValue := 270 ) )
			This.Value := Round( This.SweepValue / 270 * This.Range )
			*/
			This.SweepValue := val
			This.Value := TextOutput
			This._DrawGraphics()
					if( This.Label ){
			Try	{
				gosub, % This.Label
			}
		}
			Sleep,30
		}

	}
	_DrawGraphics(){
		;Bitmap Created Using: HB Bitmap Maker
		local pBitmap, hBitmap, G, Pen, Brush 
		pBitmap := Gdip_CreateBitmap( This.Size , This.Size ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -2 , -2 , This.Size + 4 , This.Size + 4 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.BorderColor ) , Gdip_FillEllipse( G , Brush , 2 , 2 , This.Size - 4 , This.Size - 4 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.GaugeLineBackgroundColor ) , Gdip_FillEllipse( G , Brush , 4 , 4 , This.Size - 8 , This.Size - 8 ) , Gdip_DeleteBrush( Brush )
		Pen := Gdip_CreatePen( This.MainColor , 7 ) , Gdip_DrawArc( G , Pen , 7 , 7 , This.Size - 14 , This.Size - 14 , 180 , 360 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( This.MainColor , 7 ) , Gdip_DrawArc( G , Pen , 12 , 12 , This.Size - 24 , This.Size - 24 , 180 , -90 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( This.GaugeLineColor , 1 ) , Gdip_DrawArc( G , Pen , 12 , 12 , This.Size - 24 , This.Size - 24 , 180 , This.SweepValue ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillEllipse( G , Brush , 14 , 14 , This.Size - 28 , This.Size - 28 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( This.TextColorTop ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x13 y14" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.TextColorBottom ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x15 y16" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( This.TextColor ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize " Center vCenter Bold c" Brush " x14 y15" , This.Font , This.Size - 28 , This.Size - 28 ) , Gdip_DeleteBrush( Brush )
        


            ;~ *********************************************************
		Gdip_DeleteGraphics( G )
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
		SetImage( This.hwnd , hBitmap )
		DeleteObject( hBitmap )
	}
}
Attachments
Animation.gif
Animation.gif (310.06 KiB) Viewed 1654 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], oktavimark and 270 guests