Forum Discussion

ChrisKudla's avatar
ChrisKudla
Occasional Contributor
14 years ago

Working with VCL Dev Express ExpressBars 6

Hi



I am having problems working with menus which are done using DevExpress ExpressBars6. I have followed an older post http://www.automatedqa.com/newsgroups/d.cgi?cmd=article&group=automatedqa.public.testcomplete&item=9172&utag=

but the same thing no longer works. I have tried the ESBarDemo (supplier by DevExpress) and using TestComplete 7.52 I cannot seem to access the ItemLinks and TdxBarControl_1 is not available. There is now a TxDockControl which has a TDxBarControl as a child, but this has no ItemLinks. The fact that these controls are not normally visible makes it even harder to try and work out what is going on.  



This is my script.

procedure Test;

var

p, w: OleVariant;

ItemCount, i;

begin

 
p := Sys.Process('ESBarDemo');

  w := p.ESBarDemoMainForm;

  w.Activate;

  ItemCount := w.dxBarManager1.TdxBarControl_1.ItemLinks.VisibleItemCount;

  for i := 0 to (ItemCount - 1) do

   
Log.Message(w.dxBarManager1.TdxBarControl_1.ItemLinks.VisibleItems.Caption);

end;



I would really appreciate some help here as I need to try and get the menu options working to test my app.



Regards



Chris






Test;p, w: OleVariant;ItemCount, i;p := .Process('ESBarDemo');  w := p.ESBarDemoMainForm;  w.Activate;  ItemCount := w.dxBarManager1.TdxBarControl_1.ItemLinks.VisibleItemCount;  i := 0 (ItemCount - 1) .Message(w.dxBarManager1.TdxBarControl_1.ItemLinks.VisibleItems.Caption);end;I would really appreciate some help here as I need to try and get the menu options working to test my app. RegardsChris

3 Replies


  • Hi Chris,





    We have a sample script that demonstrates how to work with items of the TdxBarManager control. The script identifies items by their captions and clicks them:







    function Main_Sample()



      // ...

      var wBarControl = wDockControl.Window("TdxBarControl", "Main Menu");

      var itemStr = "&File|&Open Practice..."; 

      if (ClickByCaption(wBarControl.BarManager, itemStr, 0))

      {

        //The menu item was successfully clicked

      }







    function ClickByCaption(manager, itemStr, level) 



      var tempResult = false;

      var currentItem;

      Log.LockEvents(1);

      

      var itemArray = itemStr.split("|");

      var itemCount = manager.GetItemCount;

      for(var itemId = 0; itemId < itemCount; itemId++)

      {

        currentItem = manager.GetItem(itemId);

        if (SameText(currentItem.Caption, itemArray[level]))

        {

          Runner.CallObjectMethodAsync(currentItem, "Click");

          if (level + 1 >= itemArray.length)

          {

            tempResult = true;

            Log.UnlockEvents();

            Log.Event("The '" + itemStr + "' menu item was left-clicked.")

            return tempResult;

          }

          else

          {

            tempResult = ClickByCaption(manager, itemStr, level + 1)

          }

        }

      }

      Log.UnlockEvents();

      if (!tempResult)

      {

        Log.Error("The '" + itemStr + "' menu item was not found.")

      }

      return tempResult;

    }






    I hope this helps.
  • ChrisKudla's avatar
    ChrisKudla
    Occasional Contributor
    Hi



    My Java Script is not too hot but running this against the Dev Express and making a small change I get the error "Type Message Time Link

    Unable to find the object BarManager. 13:25:28 

    Looking in Object Browser, there is no BarManager under the DockControl.



    My script looks like this




    function Main_Sample()


    Main_Sample()

    {


    // ...


    var wBarControl = Sys.Process("ESBarDemo").VCLObject("ESBarDemoMainForm").Window("TdxDockControl", "", 3).Window("TdxBarControl", "MainMenu", 1)


     


    var itemStr = "&File|&Open Practice...";


    if (ClickByCaption(wBarControl.BarManager, itemStr, 0))


    { Sys.Process("ESBarDemo").VCLObject("ESBarDemoMainForm").VCLObject("dxBarManager1")


    //The menu item was successfully clicked


    }


    }


    There are two BarManager items in the Object Browser.

    Sys.Process("ESBarDemo", 4).VCLObject("ESBarDemoMainForm").VCLObject("dxBarManager1Bar1")

    Sys.Process("ESBarDemo", 4).VCLObject("ESBarDemoMainForm").VCLObject("dxBarManager1")



    Regards



    Chris





  • Hi Chris,





    Most probably, this problem is caused by the fact that your application is compiled without debug information. So, try compiling your application with debug information as it is described in the Open Applications in Delphi help topic.