#Include once "window9.bi"

Function SetGadgetState(ByVal NumberGadget As integer,ByVal state As Integer) As Integer Export
  Var GID=GetProp(GadgetID(NumberGadget),"addparam60000")
  Var GID1=GadgetID(NumberGadget)
  If GadgetClass(GID)=14 Then '"MSCTLS_UPDOWN32"
    Return SendMessage(GID,WM_USER+103,0,state)
  ElseIf GadgetClass(GID1)=8 Then 'ProgressBar
    Return SendMessage(GID1,(WM_USER+2),state,0)
  Else
    If state=1 Then
      Return SendMessage(GID1,BM_SETCHECK,BST_CHECKED,0)
    ElseIf state=0 Then
      Return SendMessage(GID1,BM_SETCHECK,BST_UNCHECKED,0)
    ElseIf state=2 Then
      Return SendMessage(GID1,BM_SETCHECK,BST_INDETERMINATE,0)
    End If
  end if
End Function
