Progress control

Homepage: Enhanced Progress Bar Control
Please have a look at the homepage and the demo-program. It shows all features of the control.


Create the control
ProgressHandle := DllCall("AHKCtrlSupport\CreateProgressCtrl", int, nStyle, int, x, int, y, int, width, int, height, int, HWND, int, nID, "Cdecl Int")
ProgressHandle Handle to the new control
nStyle i.e. 0x10000000
x, y top left coordinates on the dialog
Width, Height Width and Height of the control
HWND Handle of the dialog
ID Id of the new control



Set ToolTip-text and style
nRC := DllCall("AHKCtrlSupport\SetProgressTooltip", int, ProgressHandle, str, szText, int, 768, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
szText Text for the Tooltip
Style 0x0100 = Show Percent
0x0200 = Show Position
0x0300 = Show Text only



Set Position
nRC := DllCall("AHKCtrlSupport\SetProgressPosStep", int, ProgressHandle, int, 20, "Cdecl Int")
nRC New Position
ProgressHandle Handle to the control
int New Position
Step Each step should advance the bar x steps



Set Range
nRC := DllCall("AHKCtrlSupport\SetProgressRange", int, ProgressHandle, int, 0, int, 100, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int Start at
Step Run to



Set Font
nRC := DllCall("AHKCtrlSupport\SetProgressFont", int, ProgressHandle, int, nHeight, int, nWidth, int, nEscapement, int, nOrientation, int, nWeight, int, nItalic, int, nUnderline, int, nStrikeout, int, nCharSet, int, nOutPrec, int, nClipPrec, int, nQuali, int, nPitch, str, "Arial", "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
Rest of parameters Have a look at that site: CFont::CreateFont



Modify Style
nRC := DllCall("AHKCtrlSupport\SetProgressStyle", int, ProgressHandle, int, nAdd, int, nDel, "Cdecl Int")

nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int Style to add
int Style to remove
List of Style LEFT 0x0010L
RIGHT 0x0020L
CENTER 0x0030L
TOP 0x0040L
BOTTOM 0x0080L
VCENTER 0x00C0L



Set animationstyle
nRC := DllCall("AHKCtrlSupport\SetProgressAnimation", int, ProgressHandle, int, nms, int, nStep, int, nSnakeAni, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int nms: ms to wait between steps
int How many steps should the animation do at once
int 0= Snake
1= Animation



Set Color
nRC := DllCall("AHKCtrlSupport\SetProgressColor", int, ProgressHandle, int, 0x0000FF, int, 0x004444, int, 0xff0000, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int Text color
int Text background color
int Background color



Set gradient
nRC := DllCall("AHKCtrlSupport\SetProgressGradient", int, ProgressHandle, int, 0xFF0000, int, 0x0000FF, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int starting color
int ending color



Set progress text.

you MUST NOT specify a %-sign within the text

nRC := DllCall("AHKCtrlSupport\SetProgressText", int, ProgressHandle, str, szText, int, nType, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
szText Text to display
nType 0x0100 = Show Percent
0x0200 = Show Position
0x0300 = Show Text only



Set rubber band and tied
nRC := DllCall("AHKCtrlSupport\SetProgressRubberTied", int, ProgressHandle, int, EvenOdd, int, EvenOdd, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
0 | 1 Use rubber band. The gradient is drawed as far as the bar is advanced | The gradient grows with the bar
0 | 1 Draw the text centered | Draw the text centered inside the growing bar



Set borders
nRC := DllCall("AHKCtrlSupport\SetProgressBorders", int, ProgressHandle, int, nBorders, int, nBorders, int, nBorders, int, nBorders, "Cdecl Int")
nRC 0 = error, <> 0 = ok
ProgressHandle Handle to the control
int Shrink the bar x pixel (x1-coordinate)
int Shrink the bar x pixel (y1-coordinate)
int Shrink the bar x pixel (x2-coordinate)
int Shrink the bar x pixel (y2-coordinate)



Example:
; ------------------------------------ Progress Control ----------------------------------------
; ----------------------------------------------------------------------------------------------
x = 260
y = 350
width = 200
height = 50
nID = 115
nStyle = 0
ProgressHandle := DllCall("AHKCtrlSupport\CreateProgressCtrl", int, nStyle, int, x, int, y, int, width, int, height, int, HWND, int, nID, "Cdecl Int")
if (errorlevel <> 0) || (ProgressHandle = 0)
{
	MsgBox error while calling CreateProgressCtrl Errorlevel: %errorlevel% - ProgressHandle: %ProgressHandle%
	return
}
szText=ToolTipText Progress
nRC := DllCall("AHKCtrlSupport\SetProgressTooltip", int, ProgressHandle, str, szText, int, 768, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressTooltip Errorlevel: %errorlevel% - RC: %nRC%
	return
}
nRC := DllCall("AHKCtrlSupport\SetProgressPosStep", int, ProgressHandle, int, 1, int, 1, "Cdecl Int")
if (errorlevel <> 0)
{
	MsgBox error while calling SetProgressPosStep Errorlevel: %errorlevel%
	return
}
nRC := DllCall("AHKCtrlSupport\SetProgressRange", int, ProgressHandle, int, 1, int, 170, "Cdecl Int")
if (errorlevel <> 0)
{
	MsgBox error while calling SetProgressRange Errorlevel: %errorlevel%
	return
}
nHeight = 15
nWidth = 5
nEscapement = 0
nOrientation = 0
nWeight = 15
nItalic = 0
nUnderline = 1
nStrikeout = 0
nCharSet = 0
nOutPrec = 0
nClipPrec = 0
nQuali = 0
nPitch = 0
szFontName = Arial
nRC := DllCall("AHKCtrlSupport\SetProgressFont", int, ProgressHandle, int, nHeight, int, nWidth, int, nEscapement, int, nOrientation, int, nWeight, int, nItalic, int, nUnderline, int, nStrikeout,  int, nCharSet, int, nOutPrec, int, nClipPrec, int, nQuali, int, nPitch, str, "Arial", "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressFont Errorlevel: %errorlevel% - RC: %nRC%
	return
}
nStyle2Add = 30
nStyle2Del = 0
nRC := DllCall("AHKCtrlSupport\SetProgressStyle", int, ProgressHandle, int, nStyle2Add, int, nStyle2Del, "Cdecl Int")
if (errorlevel <> 0)
{
	MsgBox error while calling SetProgressStyle Errorlevel: %errorlevel%
	return
}
;nRC := DllCall("AHKCtrlSupport\SetProgressAnimation", int, ProgressHandle, int, 50, int, 1, int, 1, "Cdecl Int")
;if (errorlevel <> 0)
;{
;	MsgBox error while calling SetProgressAnimation Errorlevel: %errorlevel%
;	return
;}
nRC := DllCall("AHKCtrlSupport\SetProgressColor", int, ProgressHandle, int, 0x00FFFF, int, 0x444444, int, 0xffFF00, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressColor Errorlevel: %errorlevel% - RC: %nRC%
	return
}
nRC := DllCall("AHKCtrlSupport\SetProgressGradient", int, ProgressHandle, int, 0xFF0000, int, 0x0000FF, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressGradient Errorlevel: %errorlevel% - RC: %nRC%
	return
}
ProgressCounter = 1
ProgressLoops = 1
SetTimer, ProgressStep, 100
return

ProgressStep:
ProgressCounter += 1
nRC := DllCall("AHKCtrlSupport\SetProgressStep", int, ProgressHandle, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressStep Errorlevel: %errorlevel% - RC: %nRC%
	return
}
if (ProgressCounter > 30 ) && (ProgressCounter < 80 )
{
	szText = Absolute counter of
	nType = 0x200
}
else
{
	szText = Percent counter of
	nType = 0x100
}
nRC := DllCall("AHKCtrlSupport\SetProgressText", int, ProgressHandle, str, szText, int, nType, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling SetProgressText Errorlevel: %errorlevel% - RC: %nRC%
	return
}
if ProgressCounter = 170
{
	;Set to zero
	nRC := DllCall("AHKCtrlSupport\SetProgressPosStep", int, ProgressHandle, int, 1, int, 1, "Cdecl Int")
	if (errorlevel <> 0) || (nRC = 0)
	{
		MsgBox error while calling SetProgressPosStep Errorlevel: %errorlevel%  - RC: %nRC%
		return
	}
	ProgressCounter = 1
	ProgressLoops += 1
	EvenOdd := mod(ProgressLoops, 2)
	ToolTip EvenOdd: %EvenOdd%
	nRC := DllCall("AHKCtrlSupport\SetProgressRubberTied", int, ProgressHandle, int, EvenOdd, int, EvenOdd, "Cdecl Int")
	if (errorlevel <> 0) || (nRC = 0)
	{
		MsgBox error while calling SetProgressRubberTied Errorlevel: %errorlevel%  - RC: %nRC%
		return
	}
}
return