Dynamically manipulate a menu to create an MRU in a Windows app in Progress - dynamic

I have a Windows application written in Progress. I'm working with version 10.1C. I would like to add MRU functionality to the menu, i.e. I want to add, remove and modify menu items in the application's File menu, to show the user's most recent files in the order in which they were used. I've done this often enough in a number of other languages, it's a pretty common feature and very easy to do.
But how would one do this in Progress? In another language I could have created 10 menu items and simply made the unused ones invisible, but you can't do that in Progress. I can't imagine why.
Alternatively, I should be able to dynamically create menu items as needed and add them to the end of the MRU list in the File menu, but I can't seem do that either: Firstly, I can't specify where in the File menu the item must be added, it always adds it to the bottom, and secondly, I can't add dynamic menus to static menus, so I can't add my MRU menus to the existing File menu. I can do it if I make the whole File menu dynamic (which I really don't want to do), but then I can't add the dynamic File menu to the static menu bar. This leaves me with the unacceptable option of making the entire menu structure dynamic.
Does anybody have any ideas?
Using Ade's answer below, here is a brief example of how I achieved it. Changing the labels and values of the MRU items doesn't require any fiddling, just set the appropriate attributes, but in order to add new MRU items, I have to remove and recreate the Exit menu item:
/* Remove the RULE and Exit menu items */
IF VALID-HANDLE(ghMenuRule) THEN DELETE OBJECT ghMenuRule.
IF VALID-HANDLE(ghMenuExit) THEN DELETE OBJECT ghMenuExit.
/*
...
Coding to add MRU items.
...
*/
/* Create the RULE and Exit menu items */
CREATE MENU-ITEM ghMenuRule
ASSIGN
SUBTYPE = "RULE"
PARENT = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win.
CREATE MENU-ITEM ghMenuExit
ASSIGN
PARENT = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win
LABEL = "E&xit"
TRIGGERS:
ON CHOOSE PERSISTENT RUN ExitApp IN THIS-PROCEDURE.
END TRIGGERS.
The actual MRU items are created just like the Exit menu is created here, except that I store the handles in a temp-table.
The result is a menu like this:
File
New
Open
--------
Print Setup
Print
--------
1 Mru item
2 Mru Item
3 Mru Item
--------
Exit

create a static menu MENU-BAR-C-Win.
add static sub-menu "File" m_file.
add static menu-item (use ">>") "Exit" (m_Exit) to m_file.
define....
DEFINE VARIABLE hMRU#1 AS HANDLE NO-UNDO.
create a button to dynamically...
CREATE MENU-ITEM hMRU#1
ASSIGN
PARENT = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win
LABEL = "MRU#1"
TRIGGERS:
ON CHOOSE PERSISTENT RUN SomeThing IN THIS-PROCEDURE.
END TRIGGERS.
you'll want to keep track of your handles (temp-table?) some how.

Related

VBA - Create a menu list when you right click a listbox

I would like to have a menu with two options when user right clicks listbox.
With that menu user would do some actions on selected data, e.g. add new line, change some columns data or delete row. I think I can manage that code but I can not grasp how to create a right click custom menu.
I can not find a way to create such option. Does anyone has an idea?
Here's some code for the right click event:
Select ListBox item on rightclick in Word VBA
Replace this code with your context menu code:
Me.Caption = derivedIndex & " = " & ListBox1.List(derivedIndex)
Here's a example for the popup menu (you need skills to understand Win32 API calls...)
https://www.vbarchiv.net/api/api_createpopupmenu.html
The right click menu on the listbox that created by using only a class(without using Api or Declare function) contains the following buttons ;
Increase Font Size
Decrease Font Size
Sort A-Z
Remove List
Remove All
For VBA codes and sample file review this link

Tosca: How to scan Dropdown textbox which disapper upon opening xScan

I have a problem in scanning a drop-down menu which disappears upon opening the xScan. I need to get the module id of the dropdown menu to verify some test steps.
Do you have any solution with this if it is not really possible to get the module id of the dropdown menu?
Open developer tools in your browser of choice (F12), navigate to the console and input the following code:
var fulldoc='';
var scrollX=0;
var scrollY=0;
document.addEventListener("keydown",function(event){
if(event.key=='q' && event.altKey){
fulldoc=document.body.outerHTML;
scrollY=window.pageYOffset;
scrollX=window.pageXOffset;
}
if(event.key=='w' && event.altKey){
document.body.outerHTML=fulldoc;
document.body.scrollTo(scrollX,scrollY);
}
});
When the window looks the way you would want to scan, press 'Alt + Q', then press 'Alt + W'.
Now your window will freeze and then you can scan your page.
To steer the objects you need to refresh your browser.
You can resolve the issue with below 2 steps
1 - Add some text in textbox which will populate the dropdown below it .
2 - Use Send Keys Module to scroll down and select the value.
I had a similar issue where we had a popup that only appeared when clicking on a text box. The solution we received from the Tricentis trainer was as follows:
Part One
1. Open your application in Chrome
2. Right click the inspect
3. In the inspector window, on the Elements tab, navigate to your html element where it should be (you can do that by clicking on the element and check that you can see the html in the element)
4. Use the debugger to add a break point there, this should pause it and you should be able to see the elements you need to steer it.
5. Once you found the element, you will need the type of element (e.g. div, span, etc), and the class name
Part two
1. Rescan your module and select any element that matches the criteria of your element selected in Part One #5
2. Identify it by only it's class name property and tag
3. Save and close
4. Edit the element in the module view by changing the class name. This should help you steer it
Note: if the element class name is not unique, you might need to use Explicit name.
Good luck

Error: "The item with the specified name wasn't found."

I've been looking for this problem, but cannot find a solution that works for me.
I've made option buttons through the UI of word 2013 , and gave them a specified name in their properties ( "knop11" )
ThisDocument.Shapes("knop11").Visible = False
The above line is what I try to use to hide my option button when pressing a command button.
After making a new option button ( with default name "OptionButton1 ) it still doesn't work if I apply it to that button.
It depends on the type of control you are inserting, if you are using a ActiveX option button, it is not included within the shapes, but it will be created as an independent object. In such case you just have to use its functions directly.
However there is no 'visibility' property within option buttons, you might use a harsh work around like changing the buttons size or its forecolor. Something like:
If knop11.Height > 1 Then
knop11.Height = 1
Else
knop11.Height = 20
End If
Just as a quick tip, when you make the UI, the controls that are included within the shapes of the document are the ContentControls, and normally you fill the TAG property to look for them later. You might as well use the check box content control, and programming the option behaviour within your macros.

Save a user popup selection in a custom Automator Action

Using Xcode 5.* for a cocoa-applescript automator action.
Interface is a a simple popup menu that gets populated using an outlet with:
tell thePopupMenu to removeAllItems()
tell thePopupMenu to addItemsWithTitles_(theList)
When the action is used in a workflow (a Service actually), I want the next time it is run and the action dialog shows up (I will have "Options:Show when run" selected), I want the popup menu to change the selection to the last one that was selected. Right now, the default first item shows, even though last time it was run, the user selected a different item in the popup menu.
My thought was that I need to capture a change in the popup menu with a Sent Action handler, and then set some type of default. I have a working handler:
on thePopupMenuSentAction_(sender)
set popupValue to (popupSelectedValue of my parameters()) as string
-- save this selection somewhere???
end
What's the right way to save this? Do I use User Defaults? My Bindings are currenly all tied through Parameter object/controller. If I should use User Defaults, can someone give example code for setting up User Defaults, and then how to get and set a new value using Cocoa-Applescript?
If I can get the name string of the menu item saved somewhere, I can get the string and then change the selection of the popup menu in the
on opened {}
-- set up the action interface
end
handler which gets called just before the action is displayed each time.
Thanks for any help,
Joe
I did mine a bit differently. I will assume you are referring to what XCode calls a "pop up button" (somewhat misleading). I did not use the parameters at all, although that is probably better for larger projects. Have a look at the code:
script Insert_Picture_into_Powerpoint_Slide_Show
property parent : class "AMBundleAction"
property menuChoices : {"Insert a Beginning", "Insert at End"}
property menuSelection : missing value
if (menuSelection as string) is "missing value"
set menuSelection to 0 as integer -- sets default value
end if
end script
I bound Content Values to File's Owner and under Model Key Path I put menuChoices.
Then you just bind the Selected Index to File's Owner and for the Model Key Path type menuSelection.
Defaults
On the initial run, if the user does not click anything, the menuSelection will be missing value. Because I couldn't find a way around this, I created a conditional which tests for this and sets it to the first choice by default (the one that is shown when you add the action).
When the user selections one of the menu choices, the choice is remembered on sequential runs.

Populating options for drop down list

I have a list that I will have users enter data into, each user needs to select their own location. First I created a drop down field with all the options. The column can be set to force unique values, but this doesnt check until the end when the user goes to save.
Is there a way to check if the users selection is already entered, immediately when the option is selected? (without having to hit save)
OR
Another option I tried was:
Create a separate list with two columns: name and saved. Call it Location_List
Create a view that displays all where saved = no on Location_list
Populate the options on the mainList from a look up the the Location_List. This works.
Add a workflow action to mainList that updates saved = yes on the Location_List. This part doesn't work. Does sharepoint allow this though?
Is there an easier way to accomplish this?
My second option worked, had simply forgotten to update the workflow setting to "Start automatically when item is created" for it to run accordingly.