Drop-down menu for MV point

Hello, there is an MV point with several states (state-1, state-2, state-3, etc.). Can someone tell me
How to make a drop-down menu to select these states?
A menu of the kind shown in the picture (taken from another SCADA, where this element is present directly on the toolbar)

Parents
  • Q5085 How to create a combo box

    ArticleID: Q5085
    Created: 22/09/2008
    Last Updated: 22/09/2008
    Suggested By: Warwick Black

    Applies To:
    CitectSCADA 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectHMI 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectFacilities 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectSCADA Batch 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectSCADA Pocket 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
     



    --------------------------------------------------------------------------------
    Summary:
    How do I create a combo box?

     

    Solution:
    There are 2 ways to do it, Use:


    * ActiveX combo box, or
    * ciText.combobox.
    To use an ActiveX combo box:


    Paste the activeX control “Microsoft Forms 2.0 ComboBox” on a graphics page
    Associate the TEXT property with a Tag. This tag will contain the value of the item selected from the ComboBox.


    FUNCTION MyPageLoad()
       OBJECT oComboBox1
       INT iIndex
       oComboBox1 = ObjectByName("AN210")
       _ObjectCallMethod(oComboBox1,"Clear")
       _ObjectCallMethod(oComboBox1,"AddItem","Tag1",iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem","Tag2",iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem","Tag3",iIndex)
    END

    FUNCTION MyPageLoad2()
       OBJECT oComboBox1
       INT iIndex
       oComboBox1 = ObjectByName("AN210")
       _ObjectCallMethod(oComboBox1,"Clear")
       _ObjectCallMethod(oComboBox1,"AddItem",Tag1,iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem",Tag2,iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem",Tag3,iIndex)
       iIndex = iIndex + 1
    END

    To use a ciText combo box:

    Use example project
    Paste the following function to Recipe.Ci file
    Configure a device using DBF file type (as we are using Example project, Recipe.dbf already exists)
    Insert CiText.ComboBox on a graphics page (Say page "Recipe")
    Find out the animation point occupied by this control
    Add a button on this page as well and call the following function in the command field LoadRecipe2ComboBox("AN35")
    Compile the project
    Run the project


    FUNCTION LoadRecipe2ComboBox(STRING sAN)
       STRING sName;
       OBJECT oComboBox1;
       INT iComboBoxIndex1 = 0;
       INT iRecNo;
       IF hRecipe < 0 THEN
          hRecipe = DevOpen("Recipes", 0);
       END
       IF hRecipe >= 0 THEN
          iRecNo = DevRecNo(hRecipe); !Current Record Number
          DevSeek(hRecipe, 1);
          oComboBox1 = ObjectByName(sAN);
          _ObjectCallMethod(oComboBox1, "Clear");
          WHILE NOT DevEOF(hRecipe) DO
             sName = DevGetField(hRecipe, "Name");
             _ObjectCallMethod(oComboBox1, "AddItem", sName,
             iComboBoxIndex1);
             iComboBoxIndex1 = iComboBoxIndex1 + 1;
             DevNext(hRecipe);
          END
          DevSeek(hRecipe, iRecNo); // Reinstate the original position
       ELSE
          Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
       END
    END

    If you want to use the function with other applications, you should modify it accordingly. For example, if you have more than one ComboBox on a page, you could code the function as generic one as shown below. Simply pass the device handle, animation point number and data field name. Note that you want the function to be call on page entry, you have to delay the call until the control is instantiated. In V6, a new page event called "On page shown" is introduced that guarantee all objects are instantiated. Hope this would help.


    FUNCTION LoadRecipe2ComboBox(INT hRecipe, STRING sAN, STRING sFieldName)
       STRING sName;
       OBJECT oComboBox1;
       INT iComboBoxIndex1 = 0;
       INT iRecNo;
       IF hRecipe >= 0 THEN
          iRecNo = DevRecNo(hRecipe); !Current Record Number
          DevSeek(hRecipe, 1);
          oComboBox1 = ObjectByName(sAN);
          _ObjectCallMethod(oComboBox1, "Clear");
          WHILE NOT DevEOF(hRecipe) DO
             sName = DevGetField(hRecipe, sFieldName);
             _ObjectCallMethod(oComboBox1, "AddItem", sName,
             iComboBoxIndex1);
             iComboBoxIndex1 = iComboBoxIndex1 + 1;
             DevNext(hRecipe);
          END
          DevSeek(hRecipe, iRecNo); // Reinstate the original position
       ELSE
          Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
       END
    END


    see the KB CitectSCADA KB 2013-05-28.chm
     

Reply
  • Q5085 How to create a combo box

    ArticleID: Q5085
    Created: 22/09/2008
    Last Updated: 22/09/2008
    Suggested By: Warwick Black

    Applies To:
    CitectSCADA 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectHMI 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectFacilities 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectSCADA Batch 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
    CitectSCADA Pocket 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
     



    --------------------------------------------------------------------------------
    Summary:
    How do I create a combo box?

     

    Solution:
    There are 2 ways to do it, Use:


    * ActiveX combo box, or
    * ciText.combobox.
    To use an ActiveX combo box:


    Paste the activeX control “Microsoft Forms 2.0 ComboBox” on a graphics page
    Associate the TEXT property with a Tag. This tag will contain the value of the item selected from the ComboBox.


    FUNCTION MyPageLoad()
       OBJECT oComboBox1
       INT iIndex
       oComboBox1 = ObjectByName("AN210")
       _ObjectCallMethod(oComboBox1,"Clear")
       _ObjectCallMethod(oComboBox1,"AddItem","Tag1",iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem","Tag2",iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem","Tag3",iIndex)
    END

    FUNCTION MyPageLoad2()
       OBJECT oComboBox1
       INT iIndex
       oComboBox1 = ObjectByName("AN210")
       _ObjectCallMethod(oComboBox1,"Clear")
       _ObjectCallMethod(oComboBox1,"AddItem",Tag1,iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem",Tag2,iIndex)
       iIndex = iIndex + 1
       _ObjectCallMethod(oComboBox1,"AddItem",Tag3,iIndex)
       iIndex = iIndex + 1
    END

    To use a ciText combo box:

    Use example project
    Paste the following function to Recipe.Ci file
    Configure a device using DBF file type (as we are using Example project, Recipe.dbf already exists)
    Insert CiText.ComboBox on a graphics page (Say page "Recipe")
    Find out the animation point occupied by this control
    Add a button on this page as well and call the following function in the command field LoadRecipe2ComboBox("AN35")
    Compile the project
    Run the project


    FUNCTION LoadRecipe2ComboBox(STRING sAN)
       STRING sName;
       OBJECT oComboBox1;
       INT iComboBoxIndex1 = 0;
       INT iRecNo;
       IF hRecipe < 0 THEN
          hRecipe = DevOpen("Recipes", 0);
       END
       IF hRecipe >= 0 THEN
          iRecNo = DevRecNo(hRecipe); !Current Record Number
          DevSeek(hRecipe, 1);
          oComboBox1 = ObjectByName(sAN);
          _ObjectCallMethod(oComboBox1, "Clear");
          WHILE NOT DevEOF(hRecipe) DO
             sName = DevGetField(hRecipe, "Name");
             _ObjectCallMethod(oComboBox1, "AddItem", sName,
             iComboBoxIndex1);
             iComboBoxIndex1 = iComboBoxIndex1 + 1;
             DevNext(hRecipe);
          END
          DevSeek(hRecipe, iRecNo); // Reinstate the original position
       ELSE
          Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
       END
    END

    If you want to use the function with other applications, you should modify it accordingly. For example, if you have more than one ComboBox on a page, you could code the function as generic one as shown below. Simply pass the device handle, animation point number and data field name. Note that you want the function to be call on page entry, you have to delay the call until the control is instantiated. In V6, a new page event called "On page shown" is introduced that guarantee all objects are instantiated. Hope this would help.


    FUNCTION LoadRecipe2ComboBox(INT hRecipe, STRING sAN, STRING sFieldName)
       STRING sName;
       OBJECT oComboBox1;
       INT iComboBoxIndex1 = 0;
       INT iRecNo;
       IF hRecipe >= 0 THEN
          iRecNo = DevRecNo(hRecipe); !Current Record Number
          DevSeek(hRecipe, 1);
          oComboBox1 = ObjectByName(sAN);
          _ObjectCallMethod(oComboBox1, "Clear");
          WHILE NOT DevEOF(hRecipe) DO
             sName = DevGetField(hRecipe, sFieldName);
             _ObjectCallMethod(oComboBox1, "AddItem", sName,
             iComboBoxIndex1);
             iComboBoxIndex1 = iComboBoxIndex1 + 1;
             DevNext(hRecipe);
          END
          DevSeek(hRecipe, iRecNo); // Reinstate the original position
       ELSE
          Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
       END
    END


    see the KB CitectSCADA KB 2013-05-28.chm
     

Children
No Data