Progress Programming Tips

By Rod Gaither (rdg@worldinfo.com)


PPT-4  Applying Windows Level Events

Tip:

When you need to "Make" an event in the Windows environment
happen that Progress does not support you can use a direct
call to Windows to apply the event.  As an example here is
a way for a program to make the popup menu of a widget appear.

---- Code insert begins ----

/*** define external procedure to send message **/
PROCEDURE SendMessage EXTERNAL "user.exe":
  DEFINE INPUT PARAMETER win-handle AS SHORT.
  DEFINE INPUT PARAMETER win-msg    AS SHORT.
  DEFINE INPUT PARAMETER win-param1 AS SHORT.
  DEFINE INPUT PARAMETER win-param2 AS LONG.
END.

/*** define external procedure to set cursor position **/
PROCEDURE SetCursorPos EXTERNAL "user.exe":
  DEFINE INPUT PARAMETER x-pos AS SHORT.
  DEFINE INPUT PARAMETER y-pos AS SHORT.
END.

PROCEDURE drop-popup-menu :
/*--------------------------------------------------------------------
----------
  Purpose:     Allows programmatic dropping of popup-menu for a widget
  Parameters:  Widget handle Notes:       This is quite a workaround
  and will need some testing.
               RDG - WARNING, Hardcoded height pixel offset.
----------------------------------------------------------------------
--------*/

  DEFINE INPUT PARAMETER  p-wh   AS WIDGET-HANDLE  NO-UNDO.

  DEF VAR  t-xpos    AS INT  NO-UNDO.
  DEF VAR  t-ypos    AS INT  NO-UNDO.
  DEF VAR  t-absx    AS INT  NO-UNDO.
  DEF VAR  t-absy    AS INT  NO-UNDO.
  DEF VAR  t-lparam  AS INT  NO-UNDO.
  DEF VAR  t-hdl     AS INT  NO-UNDO.
  DEF VAR  t-frmhdl  AS WIDGET-HANDLE  NO-UNDO.


  ASSIGN
    t-hdl     = p-wh:HWND
    t-frmhdl  = p-wh:FRAME
    t-xpos    = p-wh:X + 2
    t-ypos    = p-wh:Y + 2
    t-lparam  = (t-ypos * 65536) + t-xpos   /** y in high word, x in
    low  **/ t-absx    = CURRENT-WINDOW:X + p-wh:X 
              + p-wh:WIDTH-PIXELS - 2       /** positioning right side
                 **/
    t-absy    = CURRENT-WINDOW:Y + p-wh:Y 
              + 285.                        /** Title, menubar etc. ??
                 **/

  RUN SetCursorPos (INPUT t-absx, INPUT t-absy).
  RUN SendMessage (INPUT t-hdl, INPUT 516, INPUT 2, INPUT t-lparam).
  RUN SendMessage (INPUT t-hdl, INPUT 517, INPUT 0, INPUT t-lparam).

END PROCEDURE.

---- Code insert ends ----

Wisdom:

Learn more than one programming language.  The exercise will
teach the concepts of programming not the specifics of syntax.


Rod Gaither                  | rdg@worldinfo.com
World Information Systems    | (910) 333-2580  Voice
Greensboro, NC               | (910) 333-2584  Fax