#include once "window9.bi"

Sub SetGadgetState(ByVal iGadget As Long, ByVal iState As long) Export
	dim as hwnd hWin = GadgetID(iGadget)
	dim as hwnd hExtWin = GetProp(hWin,"addparam60000")
	If win9GetGadgetClass(hExtWin)=14 Then '"MSCTLS_UPDOWN32"
		SendMessage(hExtWin,UDM_SETPOS32,0,CInt(iState))
	ElseIf win9GetGadgetClass(hWin)=8 Then 'ProgressBar
		SendMessage(hWin,PBM_SETPOS,CInt(iState),0)
	Else
		If iState=1 Then
			SendMessage(hWin,BM_SETCHECK,BST_CHECKED,0)
		ElseIf iState=0 Then
			SendMessage(hWin,BM_SETCHECK,BST_UNCHECKED,0)
		ElseIf iState=2 Then
			SendMessage(hWin,BM_SETCHECK,BST_INDETERMINATE,0)
		End If
	end if
End Sub
