Consultor Eletrônico



Kbase 20964: How to know the current position of the mouse?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   19/01/2005
Status: Unverified

GOAL:

How to determine the current location of the mouse in a Progress window?

GOAL:

How to know the current position of the mouse?

GOAL:

How to retrieve the current position of the mouse

FIX:

There are two options:
- Use the LAST-EVENT system handle and the X and attributes.

For example, add the following code to your mouse event
trigger:

MESSAGE LAST-EVENT:X
LAST-EVENT:Y VIEW-AS ALERT-BOX.


- Call the GetCursorPos and ScreenToClient APIs from user32.dll:

PROCEDURE GetCursorPos EXTERNAL "user32.dll" :
DEFINE INPUT-OUTPUT PARAMETER lRect AS MEMPTR.
END.

PROCEDURE ScreenToClient EXTERNAL "user32.dll" :
DEFINE INPUT PARAMETER hWnd AS LONG.
DEFINE INPUT PARAMETER lpPoint AS MEMPTR.
END PROCEDURE.


ON 'MOUSE-SELECT-DBLCLICK':U ANYWHERE
DO:
DEFINE VARIABLE lp AS MEMPTR NO-UNDO.
DEFINE VARIABLE X AS INTEGER NO-UNDO.
DEFINE VARIABLE Y AS INTEGER NO-UNDO.

SET-SIZE( lp ) = 16.

RUN GetCursorPos( INPUT-OUTPUT lp).

/* Show the location of the mouse relative to the frame */
RUN ScreenToClient (INPUT FRAME {&FRAME-NAME}:HWND,
INPUT lp ).

X = GET-LONG( lp, 1 ).
Y = GET-LONG( lp, 5 ).

MESSAGE X Y SKIP VIEW-AS ALERT-BOX.

SET-SIZE( lp ) = 0.

END.