How to get position in scrollable frame

In our application I am implementing some drag & drop functionality.
I am using a combination of the start-move and end-move triggers and the current position of the mouse.
However, my frame is a scrollable one and as long as the frame is in its top position (ie, not scrolled) all works well.
As soon as my frame is scrolled, things are falling apart.
I need a way to know how far the frame is scrolled, or: what is the viewport?

Anyone a suggestion?
 
My first thought was to try an adapt this to create a dynamic widget and get the position from there but could not get it to work:

Code:
GOAL: How to scroll a frame so a specific button will come in the displayed area ?

FIX:
Create a dynamic fill-in at the button coordinates, apply 'entry' to that fill-in and after that delete the fill-in object. This will force the frame to scroll to the position of that button.
Example below will move a button in a frame and the frame will scroll following the button, so the button always remain in the visible area of the frame:

DEFINE BUTTON btn LABEL "Button".
DEFINE VARIABLE whField AS WIDGET NO-UNDO.
DEFINE FRAME MyFrame WITH SIDE-LABELS.

ASSIGN
    FRAME MyFrame:WIDTH-PIXELS = 380
    FRAME MyFrame:HEIGHT-PIXELS = 320
    FRAME MyFrame:SCROLLABLE = TRUE
    FRAME MyFrame:VIRTUAL-HEIGHT-PIXEL = 1000
    FRAME MyFrame:BGCOLOR = 8.

ENABLE btn WITH FRAME MyFrame.
btn:Y = 300.
btn:X = 20.
VIEW FRAME MyFrame.
ON CHOOSE OF btn
DO:
    btn:Y = btn:Y + 30.
    DO:    
        CREATE FILL-IN whField
            ASSIGN
            ROW = btn:ROW
            COLUMN = btn:COLUMN
            FRAME = btn:FRAME
            SENSITIVE = TRUE
            VISIBLE = TRUE.
        whField:SENSITIVE = YES.
        APPLY 'ENTRY' TO whField.
        DELETE OBJECT whField.
    END.
END.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

The only other thing I could think of is force the frame to the top position when the drag & drop fires which is a bit messy:

 
Another thought, does GetScrollPos give you any information that you can make use of?:

Code:
DEFINE VARIABLE hPos AS INTEGER NO-UNDO.
DEFINE VARIABLE vPos AS INTEGER NO-UNDO.

RUN GetScrollPos(FRAME FRAME-NAME:HWND, 0, OUTPUT hPos).
RUN GetScrollPos(FRAME FRAME-NAME:HWND, 1, OUTPUT vPos).
MESSAGE hPos vPos VIEW-AS ALERT-BOX.

PROCEDURE GetScrollPos EXTERNAL "user32.dll" :
    DEFINE INPUT PARAMETER hWnd AS LONG NO-UNDO.
    DEFINE INPUT PARAMETER nBar AS LONG NO-UNDO.
    DEFINE RETURN PARAMETER pos AS LONG NO-UNDO.
END PROCEDURE.
 
Ha! That sounds promising. I will check it out tomorrow. In the mean time, I managed to find a workaround, which goes like this:

I create a lot of fill ins that can be moved around. On start-move of a widget, I read the current position of the mouse and I compare that to the position of the widget the user started to move. The difference of the Y coordinate between those two is the amount the frame has been scrolled. Seems to work right now
 
Back
Top