Search This Blog

Friday, September 9, 2011

Active X - Code to Select /Deselect checkbox in a farpoint grid activeX control cell

'****************************************************************************************************************************
'Function Name : Fun_Acx_TableCheckBox
'Description    Use this function to Select /Deselect checkbox in a farpoint grid activeX control cell
'Parameters   intRow, intCol , strOption
'           Options:
'             strOption = on :: Sets the checkbox on
'            strOption = off :: Sets the checkbox off            
'Return Val ue     True - If operation is sucess :: False - If the operation is failed
'Registerd To  AcxTable
' Ex:ample    Browser("Worklist: 322").Page("Worklist: 322").AcxTable("FarPoint Spread 6.0").Fun_Acx_TableCheckBox 3,1,"ON"
'****************************************************************************************************************************
Public Function Fun_Acx_TableCheckBox(test_object , intRow , intCol , strOption)
 Dim objPageParentObj , objBrowserParentObj

 'Initiate the function return value to false
 Fun_Acx_TableCheckBox = False
 If  test_object.Exist Then
  'Make sure the window is visble - ActiveX table control needs to be visible
  Extern.Declare micLong, "ShowWindow","user32.dll", "ShowWindow", micLong, micLong
  Set objPageParentObj = test_object.GetTOProperty("parent")
  Set objBrowserParentObj = objPageParentObj.GetTOProperty("parent")
  Extern.ShowWindow objBrowserParentObj.Object.HWND , 3
  'Perform the operation on the checkbox based on the input and return the function status
  If  Ucase(strOption) = "ON" Then
    If test_object.GetCellData(intRow , intCol + 1 ) = "(-)" Or test_object.GetCellData(intRow , intCol + 1 ) = "(+)" Then
     Do Until test_object.GetCellData(intRow , intCol + 1 ) = ""
       test_object.ActivateCell intRow , intCol
       test_object.Type " "
      intRow = intRow + 1
     Loop    
     Fun_Acx_TableCheckBox = True
    Else
      test_object.ActivateCell intRow , intCol
      test_object.Type " "
     Fun_Acx_TableCheckBox = True
    End If
  ElseIf Ucase(strOption) = "OFF" Then
    If test_object.GetCellData(intRow , intCol + 1 ) = "(-)" Or test_object.GetCellData(intRow , intCol + 1 ) = "(+)" Then
     Do Until test_object.GetCellData(intRow , intCol + 1 ) = ""
      test_object.ActivateCell intRow , intCol
      test_object.Type " "
      intRow = intRow + 1
     Loop    
     Fun_Acx_TableCheckBox = True
    Else
     test_object.ActivateCell intRow , intCol
      test_object.Type " "
     Fun_Acx_TableCheckBox = True
    End If
  End If
 End If
End Function

RegisterUserFunc "AcxTable", "Fun_Acx_TableCheckBox", "Fun_Acx_TableCheckBox"

No comments:

Post a Comment