#include once "window9.bi"

Function GetGadgetState(ByVal iGadget As Long) As Integer Export
	Dim As HWND hWin = GadgetID(iGadget)
	Dim As HWND hExtWin = GetProp(hWin,"addparam60000")
	If win9GetGadgetClass(hExtWin)=14 Then '"MSCTLS_UPDOWN32"
		return  SendMessage(hExtWin,UDM_GETPOS32,0,0)
	ElseIf win9GetGadgetClass(hWin)=8 Then 'ProgressBar
		Return SendMessage(hWin,PBM_GETPOS,0,0)
	Else
		If  IsDlgButtonChecked(GetParent(hWin),iGadget )=BST_CHECKED Then
			Return 1
		ElseIf IsDlgButtonChecked(GetParent(hWin),iGadget )=BST_INDETERMINATE Then
			Return 2
		ElseIf IsDlgButtonChecked(GetParent(hWin),iGadget )=BST_UNCHECKED Then
			Return 0
		End If
	End If
End Function

