Consultor Eletrônico



Kbase P107291: How to execute a smartToolbar action when starting a smartWindow
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   05/08/2005
Status: Unverified

GOAL:

How to execute a smartToolbar action when starting a smartWindow

GOAL:

How to initiate toolbar update actions when an ADM2 smartWindow is started.

FIX:


The simplest way to do this is to pass a parameter to the window specifying which action to take. Then override the "initializeObject" procedure in the window and after RUN SUPER get the handle of toolbar and viewer with "getContainertarget". When you have the toolbar handle you can PUBLISH the desired event (addRecord, copyRecord, deleteRecord) according to your passed in parameter. If you need to set the viewer in update mode run 'setDataModified' in the viewer and the toolbar and viewer will respond accordingly. For example:

RUN SUPER.
/* Code placed here will execute AFTER standard behavior. */
DEFINE VARIABLE ctargets AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE h_sdv AS HANDLE NO-UNDO.
DEFINE VARIABLE h_obj AS HANDLE NO-UNDO.
DEFINE VARIABLE h_toolbar AS HANDLE NO-UNDO.
DEFINE VARIABLE cname AS CHARACTER NO-UNDO.
{get containertarget cTargets}.
DO i = 1 TO NUM-ENTRIES(cTargets):
h_obj = widget-handle(ENTRY(i,cTargets)).
cname = DYNAMIC-FUNCTION('getObjectName':U IN h_Obj).
IF cname = "vcustomer" THEN
h_sdv = h_obj.
IF cname = "dyntoolbar" THEN
h_toolbar = h_obj.
END.

CASE param:
WHEN 'Add' THEN
DO:
PUBLISH "addRecord":U FROM h_toolbar.
END.
WHEN 'Copy' THEN
DO:
PUBLISH "copyRecord":U FROM h_toolbar.
END.
WHEN 'Delete' THEN
DO:
PUBLISH "deleteRecord":U FROM h_toolbar.
END.
WHEN 'Update' THEN
DO:
DYNAMIC-FUNCTION('setDatamodified':U in h_sdv, input TRUE).
END.
END CASE.