Consultor Eletrônico



Kbase P9078: How to customize the Procedure editor or Application Builder with an additional sub menu?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   19/02/2009
Status: Verified

GOAL:

How to customize the Procedure editor or Application Builder with an additional sub menu?

GOAL:

How to add a custom menu to AppBuilder?

GOAL:

How to add a custom menu to Procedure Editor?

FACT(s) (Environment):

All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The following solution adds a submenu dynamically to the AppBuilder or Procedure Editor, then it requires a minimum of customization (only one ADE file) therefore it is easier to maintain. First obtain the source code of the ADE (Application Development Environment)See Progress Solution P9621 How to obtain the source code of the ADE Add the following lines at the bottom of _adeevnt.p, create a subdirectory 'adecomm' in one of the first entries of the PROPATH (before adecomm.pl) and compile _adeevnt.p into this directory (put the .R there): /*In order to add a submenu to Procedure editor or AppBuilder*/
IF p_event = "Startup"
AND (p_product = "Editor":U OR p_product = "UIB":U)
THEN RUN ABAddMenu.p.Put the two following programs in your PROPATH: /*ABAddMenu.p*/
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.
DEFINE VARIABLE h AS HANDLE NO-UNDO.

hWin = SESSION:FIRST-CHILD.
eachWindow:
DO WHILE hWin <> ?:
/*You can also rely on h:ICON which is adeicon/uib%.ico for the AppBuilder*/
IF hWin:TITLE BEGINS "Procedure Editor"
OR hWin:TITLE BEGINS "AppBuilder" THEN DO:
h = hWin:MENU-BAR.
h = h:FIRST-CHILD.
eachSubMenu:
DO WHILE h <> ?:
IF h:NAME = "AddedMenu" THEN DO:
MESSAGE "The menu has already been added"
VIEW-AS ALERT-BOX WARNING BUTTONS OK.
RETURN.
END.
h = h:NEXT-SIBLING.
END. /*eachSubMenu*/
RUN AddAMenu.
LEAVE eachWindow.
END.
hWin = hWin:NEXT-SIBLING.
END. /*eachWindow*/

PROCEDURE AddAMenu:
DEFINE VARIABLE sm AS HANDLE NO-UNDO.

CREATE WIDGET-POOL "CustomizedADEPool" PERSISTENT NO-ERROR.
/*The above widget pool can be deleted at anytime with:
DELETE WIDGET-POOL "CustomizedADEPool" NO-ERROR.*/

CREATE SUB-MENU sm IN WIDGET-POOL "CustomizedADEPool" ASSIGN
PARENT = hwin:MENU-BAR
SENSITIVE = YES
LABEL = "He&re"
NAME = "AddedMenu".

CREATE MENU-ITEM h IN WIDGET-POOL "CustomizedADEPool" ASSIGN
PARENT = sm
SENSITIVE = YES
LABEL = "First item"
TRIGGERS:
ON CHOOSE PERSISTENT RUN ChooseAddedMenu.p (INPUT "FirstItem").
END TRIGGERS.

CREATE MENU-ITEM h IN WIDGET-POOL "CustomizedADEPool" ASSIGN
PARENT = sm
SENSITIVE = YES
LABEL = "Second item"
TRIGGERS:
ON CHOOSE PERSISTENT RUN ChooseAddedMenu.p (INPUT "SecondItem").
END TRIGGERS.
END PROCEDURE .


/* ChooseAddedMenu.p */
DEFINE INPUT PARAMETER ChoosenMenu AS CHARACTER NO-UNDO.

CASE ChoosenMenu:
WHEN "FirstItem" THEN DO:
/*do job for 1st item here...*/
END.
WHEN "SecondItem" THEN DO:
/*do job for 2nd item here...*/
END.
OTHERWISE DO:
MESSAGE "Unexpected menu item" VIEW-AS ALERT-BOX WARNING BUTTONS OK.
RETURN.
END.
END CASE.