Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter EighteenDataView Integration (continued)

on_function

Overview

The on_function event is called as a menu preprocess before the function is dispatched thus allowing for the intercept of any Forms View function.

Syntax/Parameters

Syntax

int on_function ( int id, dword lParam ) { ... }

Parameters

id

An int as the menu function code to be processed.

lParam

A dword as the ‘lParam’ for the command message from Windows. For popup menus this will be a pointer to a POINT structure.

Return Value

If the menu function is processed the event should return ERROR_EXIT (0x89000000). Any other return value will cause the menu function to be processed normally.

Remarks

Note that the function and quick keys will be passed through this event and it is up to the handler to determine whether to process them. If translated, the related menu function will be immediately passed to this event. Some functions are further passed down as other events, such as DATA_EDIT_CELL_TEXT.

It is recommended that menu IDs get looked up only once to avoid lengthy processing on every event call. Look up the menu ID and store them in a series of global variables.

Example

In this case, there are custom functions defined that we watch to capture and process. Note that since these functions are defined by the script, there are no other associated events:

                                                       /****************************************/
int on_function(int f_id, dword lParam) {              /* Function Dispatcher                  */
                                                       /****************************************/
                                                       /*                                      */
                                                       /* ** Dispatch Our Items                */
    if (f_id == fid_col_hide_empty) {                  /*  * Columns Hide Empty                */
      columns_hide_empty();                            /* Hide empty                           */
      return ERROR_EXIT;                               /* Exit as processed                    */
      }                                                /* end function                         */
    if (f_id == fid_col_selector) {                    /*  * Columns Selector                  */
      columns_selector();                              /* Hide empty                           */
      return ERROR_EXIT;                               /* Exit as processed                    */
      }                                                /* end function                         */
    if (f_id == fid_col_show_all) {                    /*  * Columns Show All                  */
      columns_show_all();                              /* Hide empty                           */
      return ERROR_EXIT;                               /* Exit as processed                    */
      }                                                /* end function                         */
                                                       /*  * Default Processing                */
    return ERROR_NONE;                                 /* Done                                 */
    }                                                  /* end function setup                   */

The variables fid_col_hide_empty, fid_col_selector and fid_col_show_all are globally defined and set when the script was initialized and the menu function added:

                                                       /****************************************/
int menu_define_functions() {                          /* Perform Menu Function Setup          */
                                                       /****************************************/
    string              fnScript;                      /* Us                                   */
    string              item[10];                      /* Menu Item                            */
    int                 rc;                            /* Return Code                          */
                                                       /*                                      */    
                                                       /* ** Add Menu Items                    */
                                                       /*  * Registration                      */
    item["Class"] = "FormsViewExtension";              /* Class Group (for all)                */
                                                       /*  o Hide Empty Columns                */
    item["Code"] = "ABS_COLUMNS_HIDE_EMPTY";           /* Function Code                        */
    item["MenuText"] = "&Hide Empty Columns";          /* Menu Text                            */
    item["Description"] = "Hide Empty Columns\r\rHides columns that do not have data.";
    rc = MenuFindFunctionID(item["Code"]);             /* Look for existing                    */
    if (IsError(rc)) {                                 /* Does not exist                       */
      rc = MenuAddFunction(item);                      /* Add the item                         */
      QuickKeyRegister("DataView",                     /* Add in quick key                     */
                       "1_KEY_CONTROL", item["Code"]); /*   to forms view                      */
      }                                                /* end error                            */
    if (IsNotError(rc)) {                              /* Found ID                             */
      fid_col_hide_empty = rc;                         /* Save                                 */
      }                                                /* end no error                         */

     . . .

 

Related Functions