SPONSORS:






User Tag List

Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Nov 2000
    Location
    Newport News, VA U.S.
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamically check if a menu item is enabled from a menu

    I'm trying to automate to dynamically check if a menu item is enabled from a menu.

    My code is similar to the following...

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    [-] main ()
    [ ]
    [ ] LIST OF WINDOW lwList = {}
    [ ] LIST OF ANYTYPE laMenuItemList = {}
    [ ]
    [ ] WINDOW wChild
    [ ] ANYTYPE aMenuItem
    [ ]
    [ ]
    [ ] Setup () // This opens the application.
    [ ]
    [ ] lwList = MyApplication.GetChildren ()
    [ ] ResPrintList ("lwList", lwList)
    [ ]
    [ ]
    [ ] ResOpenList ("MenuItemList")
    [-] for each wChild in lwList
    [ ] print ("wChild.GetCaption ():", wChild.GetCaption ())
    [ ]
    [-] if wChild.IsEnabled ()
    [ ] print ("{wChild} is enabled")
    [-] else
    [ ] LogError ("{wChild} is not enabled")
    [ ]
    [ ] laMenuItemList = wChild.GetContents ()
    [ ] ResPrintList ("{wChild}", laMenuItemList)
    [ ] ResCloseList ()
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I want to be able to do something like:

    [-]for each aMenuItem in laMenuItemList
    [ ]if wChild.aMenuItem.IsEnabled ()
    [ ]print ("{aMenuItem} is enabled")

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I get an error saying, "aMenuItemList is not a member of MyApplication.File for Microsoft Windows/NT 4.0"

    Any help would be appreciated!



    ------------------

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Waltham, MA
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    There are a couple small changes to your logic that I think will get the results you are looking for.

    Your logic should look something like ...
    [-] for each wChild in lwList
    [-] if (wChild.GetClass() == Menu)
    [ ] print ("wChild.GetCaption():",wChild.GetCaption())
    [-] if (wChild.IsEnabled())
    [ ] print ("{wChild} is enabled")
    [-] else
    [ ] LogError ("{wChild} is not enabled.")
    [ ]
    [ ] laMenuItemList = wChild.GetContents()
    [ ] ResPrintList ("{wChild}", laMenuItemList)
    [-] for each aMenuItem in laMenuItemList
    [-] if (aMenuItem.IsEnabled())
    [ ] print ("{aMenuItem}" is enabled.)
    [ ] ResCloseList ()


    The first bold line above will 'weed out' just the children that are Menus, or use JavaMenu/JavaJFCMenu, depending on the application you are testing.

    The second bold line shows that all you needed to do was remove the wChild from the call. That is automatically included in the aMenuItem.

    Hope this helps.

    [This message has been edited by BostonSilk (edited 02-01-2001).]

    [This message has been edited by BostonSilk (edited 02-02-2001).]

  3. #3
    Member
    Join Date
    Nov 2000
    Location
    Newport News, VA U.S.
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    Thank you for the reply, but it did not work.

    I'm getting an error message, "*** Error: Type mismatch -- Expecting a WINDOW"



    ------------------

  4. #4
    Senior Member
    Join Date
    Aug 1999
    Location
    Irvine, CA
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    Try the following:

    if (ClassOf(wChild) == Menu) | | (ClassOf(wChild) == MenuItem)

    You are really trying to make sure the window object is of class Menu (or even MenuItem)
    Matt Gray

  5. #5
    Member
    Join Date
    Nov 2000
    Location
    Newport News, VA U.S.
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    I'm getting the error message at this line:

    [-] if (aMenuItem.IsEnabled())


    ------------------

  6. #6
    Senior Member
    Join Date
    Mar 2000
    Location
    pisctaway, NJ USA
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    Your most likely checking if a MENU is enabled, not a menuitem. The only way you can check if a menu is enabled is by asking if one of the children is enabled and assume based on that.
    OR
    Dont check if the menu is enabled, just the items.
    Tony

  7. #7
    Senior Member
    Join Date
    Jun 2000
    Location
    Waltham, MA
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    Try changing the
    LIST OF ANYTYPE laMenuItemList to
    LIST OF WINDOW lwMenuItemList

    and change
    ANYTYPE aMenuItem to
    WINDOW wMenuItem

  8. #8
    Member
    Join Date
    Nov 2000
    Location
    Newport News, VA U.S.
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    [ ] // ************************************************** **************
    [ ] // * Purpose:
    [ ] // * Dynamically check if all the Menus are enabled and
    [ ] // * all the MenuItems within those Menus are enabled
    [ ] // * Note:
    [ ] // * This was written for Non-web application.
    [ ] // ************************************************** **************
    [ ]
    [ ] use "FrmMyApplication.inc"
    [ ]
    [-] main ()
    [ ]
    [ ] // ****** A method to open up your application
    [ ] // MyApplication.Setup ()
    [ ]
    [ ]
    [ ] VerifyMenu_and_MenuItems ()
    [ ]
    [ ]
    [ ] // ****** A method to close your application
    [ ] // MyApplication.Exit ()
    [ ]
    [ ]
    [-] testcase VerifyMenu_and_MenuItems ()
    [ ] // *****************************************
    [ ] LIST OF WINDOW lwMenuList = {}
    [ ] LIST OF WINDOW lwMenuItemList = {}
    [ ]
    [ ] WINDOW wChild
    [ ] WINDOW wChildMenuItem
    [ ]
    [ ] STRING sMenuName = ""
    [ ] STRING sMenuItem = ""
    [ ] // *****************************************
    [ ]
    [ ] // lwMenuList is a list of Menu such as File, Edit, Options, Windows,... , etc.
    [ ] lwMenuList = MyApplication.GetChildren ()
    [ ] ResPrintList ("lwMenuList", lwMenuList)
    [ ]
    [-] for each wChild in lwMenuList
    [ ]
    [ ] // 'weed out' just the children that are Menus
    [-] if (wChild.GetClass() == Menu)
    [ ]
    [ ] // For each Menu, get the name of the Menu
    [ ] sMenuName = wChild.GetCaption ()
    [ ]
    [ ] ResOpenList (sMenuName)
    [ ]
    [ ] // Check if the Menu is enabled
    [-] if wChild.IsEnabled ()
    [ ] print ("{wChild} is enabled")
    [-] else
    [ ] LogError ("{wChild} is not enabled")
    [ ]
    [ ] // Get all the MenuItems of that Menu
    [ ] // lwMenuItemList is a list of all MenuItems of a Menu
    [ ] // Example: for File Menu, it would be something like "New, Open, Close, Print, Exit"
    [ ] lwMenuItemList = wChild.GetChildren ()
    [ ] ResPrintList ("lwMenuItemList", lwMenuItemList)
    [ ]
    [-] for each wChildMenuItem in lwMenuItemList
    [ ]
    [ ] // Check if each Menu Item is enabled
    [-] if wChildMenuItem.IsEnabled ()
    [ ] print ("{wChildMenuItem} is enabled")
    [-] else
    [ ] LogWarning ("{wChildMenuItem} is not enabled")
    [ ]
    [ ] ResCloseList ()
    [-] else
    [ ] print ("'{wChild}' is not a Menu class")


    ------------------

  9. #9
    Member
    Join Date
    Nov 2000
    Location
    Newport News, VA U.S.
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamically check if a menu item is enabled from a menu

    Thank you all for your help!

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:27 PM.

Copyright BetaSoft Inc.