Tuesday, July 5, 2011

Export Coordinates workaround

I wrote the following as a kludge to get around individuals changing the coordinates of the starlims window.  Its neither pretty or the best example of coding but its functional.  Just put in in an action and call it where ever you need it.

It saves the previous form and browser locations to alternate fields (ALTFLD, ALTLINK: pre-existing fields reutilized).  It loads these values into memory, validates them against the exiting values and reapplies the original values.  The Process begins in the Preload event and ends in the ONclose event.  Pretty much required for all child windows as well as the container window or child windows lose their locations as well;

:DECLARE WindowID, nSize, check, ncheck, InitSize,chkName;

/*Allows changes made by admins but otherwise tosses input;
chkName := '<<USERNAME>>';

:IF (.NOT.chkName = 'sysadm');
/*Add more admins however necessary;

/*Originally used GetAPPID() but the function was not always consistent in returning the correct window when child windows are involved;
   WindowID:='SHELL';

    nsize := sqlexecute("Select FORMSIZE, wndorigin FROM WNDMAINT WHERE windowid = ?WindowID?", "DICTIONARY");
    InitSize := sqlexecute("Select ALTFLD, ALTLINK FROM WNDMAINT WHERE windowid = ?WindowID?", "DICTIONARY");

    :IF .NOT.comparray(InitSize, nSize);
        :DECLARE updateSize, UpdateOrig;
        UpdateSize := Initsize[1,1];
        UpdateOrig := InitSize[1,2];
            sqlexecute("Update WNDMAINT SET FORMSIZE = ?UpdateSize?, WNDORIGIN = ?UpdateOrig? Where WINDOWID=?WindowID?", "DICTIONARY");        
    :ENDIF;
:ENDIF;

No comments:

Post a Comment