#include-once #include #include #include #include #include #include Global Const $SW_HIDE = 0 Global Const $SW_SHOW = 5 Global $aProgress[1][2] Global $LV_hWnd Global $ItemIndex Global $SubItemIndex GUIRegisterMsg($WM_NOTIFY, "LV_NOTIFY") ;=================================================================================================== ; ; Function Name: _ListView_InsertProgressBar() ; Description: Inserts a progressbar control in the ListView control. ; Syntax.........: _ListView_InsertProgressBar($sHwnd, $sItemIndex[, $sSubItemIndex]) ; Parameter(s): $sHwnd - Handle to the ListView control. ; $sItemIndex - Zero based index of the item at which the progressbar should be inserted. ; $sSubItemIndex - [Optional] One based index of the subitem where progressbar should be placed, ; +default is 1. ; ; Return Value(s): Returns the identifier (controlID) of the new progressbar control. ; Requirement(s): AutoIt 3.2.10.0 and above ; Note(s): Optimal amount of progressbar controls is 5-10. Don`t abuse with many amount of progressbar controls. ; ; Author(s): R.Gilman (a.k.a rasim), arcker ; ;=================================================================================================== Func _ListView_InsertProgressBar($sHwnd, $sItemIndex, $sSubItemIndex = 1) If Not IsHWnd($sHwnd) Then $LV_hWnd = GUICtrlGetHandle($sHwnd) Else $LV_hWnd = $sHwnd EndIf Local $iStyle = _WinAPI_GetWindowLong($LV_hWnd, $GWL_STYLE) _WinAPI_SetWindowLong($LV_hWnd, BitOR($iStyle, $WS_CLIPCHILDREN), $iStyle) $ItemIndex = $sItemIndex $SubItemIndex = $sSubItemIndex Local $aRect = _GUICtrlListView_GetSubItemRect($LV_hWnd, $ItemIndex, $SubItemIndex) $aProgress[0][0] += 1 ReDim $aProgress[$aProgress[0][0] + 1][2] $aProgress[$aProgress[0][0]][0] = _Progress_Create($LV_hWnd,$aRect[0], $aRect[1], _ $aRect[2] - $aRect[0], $aRect[3] - $aRect[1]) $aProgress[$aProgress[0][0]][1] = $ItemIndex Return $aProgress[$aProgress[0][0]][0] EndFunc ;==>_ListView_InsertProgressBar Func _Progress_Create($hWnd, $iX, $iY, $iWidth=-1, $iHeight=-1, $iStyle=0, $iExStyle=0) $iStyle = BitOR($iStyle, $WS_CHILD, $WS_VISIBLE) Return _WinAPI_CreateWindowEx($iExStyle, "msctls_progress32", "", $iStyle, $iX, $iY, $iWidth, $iHeight, $hWnd) EndFunc ;==>_Progress_Create Func LV_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $iCode = DllStructGetData($tNMHDR, "Code") If ($iCode = -12) Or ($iCode = -16) Or ($iCode = -327) Then For $i = 1 To $aProgress[0][0] _MoveProgress($i, $aProgress[$i][1], $SubItemIndex) Next EndIf Return $GUI_RUNDEFMSG EndFunc ;==>LV_NOTIFY Func _MoveProgress($sProgId, $sItemIndex, $sSubItemIndex) Local $aRect = _GUICtrlListView_GetSubItemRect($LV_hWnd, $sItemIndex, $sSubItemIndex) Local $aItemRect = _GUICtrlListView_GetItemRect($LV_hWnd, $sItemIndex) If $aRect[1] < 20 And BitAND(WinGetState($aProgress[$sProgId][0]), 2) Then _WinAPI_ShowWindow($aProgress[$sProgId][0], $SW_HIDE) ElseIf $aRect[1] >= 20 And BitAND(WinGetState($aProgress[$sProgId][0]), 2) = 0 Then _WinAPI_ShowWindow($aProgress[$sProgId][0], $SW_SHOW) EndIf _WinAPI_MoveWindow($aProgress[$sProgId][0], $aRect[0], $aRect[1], _ $aRect[2] - $aRect[0], $aRect[3] - $aRect[1], True) _WinAPI_RedrawWindow($aProgress[$sProgId][0], 0, 0, $RDW_INVALIDATE) EndFunc ;==>_MoveProgress ; #FUNCTION# ==================================================================================================== ; Description ...: Sets the color of the indicator bar ; Parameters ....: $hWnd - Handle to the control ; $iColor - The new progress indicator bar color. Specify the CLR_DEFAULT value to cause the progress bar ; +to use its default progress indicator bar color. ; Return values .: Success - The previous progress indicator bar color, or CLR_DEFAULT if the progress indicator bar color ; +is the default color. ; Author ........: Paul Campbell (PaulIA), Updated By Arcker ; Remarks .......: This message is supported only in the Windows Classic theme ; Related .......: ; ==================================================================================================== Func _Progress_SetBarColor($hWnd, $iColor) Return _SendMessage($hWnd, $PBM_SETBARCOLOR, 0, $iColor) EndFunc ; #FUNCTION# ==================================================================================================== ; Description ...: Sets the current position ; Parameters ....: $hWnd - Handle to the control ; $iPos - The new position ; Return values .: Success - The previous position ; Author ........: Paul Campbell (PaulIA), Updated By Arcker ; Remarks .......: ; Related .......: _Progress_GetPos ; ==================================================================================================== Func _Progress_SetPos($hWnd, $iPos) Return _SendMessage($hWnd, $PBM_SETPOS, $iPos, 0) EndFunc ; #FUNCTION# ==================================================================================================== ; Description ...: Sets the background color in the progress bar ; Parameters ....: $hWnd - Handle to the control ; $iColor - The new background color. Specify the CLR_DEFAULT value to cause the progress bar to use its ; +default background color. ; Return values .: Success - The previous background color, or CLR_DEFAULT if the background color is the default color. ; Author ........: Paul Campbell (PaulIA), Updated By Arcker ; Remarks .......: This message is supported only in the Windows Classic theme ; Related .......: ; ==================================================================================================== Func _Progress_SetBkColor($hWnd, $iColor) Return _SendMessage($hWnd, $PBM_SETBKCOLOR, 0, $iColor) EndFunc ; #FUNCTION# ==================================================================================================== ; Description ...: Specifies the step increment ; Parameters ....: $hWnd - Handle to the control ; $iStep - Step increment. ; Return values .: Success - The previous step increment ; Author ........: Paul Campbell (PaulIA) ; Remarks .......: The step increment is the amount by which the progress bar increases its current position whenever you use the ; _Progress_StepIt function. By default, the step increment is set to 10. ; Related .......: _Progress_StepIt ; ==================================================================================================== Func _Progress_SetStep($hWnd, $iStep=10) Return _SendMessage($hWnd, $PBM_SETSTEP, $iStep, 0) EndFunc ; #FUNCTION# ==================================================================================================== ; Description ...: Advances the current position by the step increment ; Parameters ....: $hWnd - Handle to the control ; Return values .: Success - The previous position ; Author ........: Paul Campbell (PaulIA), Updated By Arcker ; Remarks .......: ; Related .......: _Progress_SetStep ; ==================================================================================================== Func _Progress_StepIt($hWnd) Return _SendMessage($hWnd, $PBM_STEPIT, 0, 0) EndFunc