• Getting current scroll position of a container

    From Andi B.@21:1/5 to Lars Erdmann on Tue Sep 15 09:03:43 2015
    Lars Erdmann schrieb:
    Am 14.09.15 20.11, schrieb Andi B.:
    Hi,
    how to get the current scroll position from a container?

    I can get the current selected object with -

    psrec = WinSendDlgItemMsg( hwnd, ulCnrId,
    CM_QUERYRECORDEMPHASIS,
    MPFROMLONG( CMA_FIRST),
    MPFROMLONG( CRA_SELECTED));

    but how can I query the scroll position (and set it again afterwards
    when I filled it with refreshed objects)?

    Thanks, Andi

    The container control has a bunch of atomic children like the 2
    scrollbars for horizontal and vertical scroll.
    I think you will have to manipulate these:

    hwndCnr = WinWindowFromID(hwnd,ulCnrId);
    // the CID_ constants are the ids of all the children controls
    hwndVertScroll = WinWindowFromID(hwndCnr,CID_VSCROLL);

    // save old vertical scroll position
    SHORT oldYPos = SHORT1FROMMR(WinSendWindowMsg(hwndVertScroll,SBM_QUERYPOS,MPVOID,MPVOID));

    ... do you stuff ...

    // restore old vertical scroll position WinSendWindowMsg(hwndVertScroll,SBM_SETPOS,MPFROMSHORT(oldYPos),MPVOID);

    I hope that that'll do.


    Lars


    Thank you very much for your input. Sounds reasonable. Will try it out.
    But it will take time until I'm back to that topic. Don't worry when I
    do not give immediate feedback :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to Lars Erdmann on Sat Sep 19 12:01:12 2015
    Lars Erdmann schrieb:
    Am 14.09.15 20.11, schrieb Andi B.:
    Hi,
    how to get the current scroll position from a container?

    I can get the current selected object with -

    psrec = WinSendDlgItemMsg( hwnd, ulCnrId,
    CM_QUERYRECORDEMPHASIS,
    MPFROMLONG( CMA_FIRST),
    MPFROMLONG( CRA_SELECTED));

    but how can I query the scroll position (and set it again afterwards
    when I filled it with refreshed objects)?

    Thanks, Andi

    The container control has a bunch of atomic children like the 2
    scrollbars for horizontal and vertical scroll.
    I think you will have to manipulate these:

    hwndCnr = WinWindowFromID(hwnd,ulCnrId);
    // the CID_ constants are the ids of all the children controls
    hwndVertScroll = WinWindowFromID(hwndCnr,CID_VSCROLL);

    // save old vertical scroll position
    SHORT oldYPos = SHORT1FROMMR(WinSendWindowMsg(hwndVertScroll,SBM_QUERYPOS,MPVOID,MPVOID));

    ... do you stuff ...

    // restore old vertical scroll position WinSendWindowMsg(hwndVertScroll,SBM_SETPOS,MPFROMSHORT(oldYPos),MPVOID);

    I hope that that'll do.


    Lars

    Ok you pointed me in the right direction. Reading scroll position works
    as you suggested. For setting back the container afterwards to the
    original position I have to use -

    // restore old vertical scroll position
    WinSendDlgItemMsg( hwnd, ulCnrId,
    CM_SCROLLWINDOW,
    MPFROMSHORT( CMA_VERTICAL ),
    MPFROMSHORT( oldYPos ));

    Your code (slightly modified to WinSendMsg instead WinSendWindowMsg)
    moves the slider only but not the content. Just in case anyone finds
    these thread some times.

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lars Erdmann@21:1/5 to Andi B. on Mon Oct 5 20:57:06 2015
    Test

    Andi B. schrieb:
    Lars Erdmann schrieb:
    Am 14.09.15 20.11, schrieb Andi B.:
    Hi,
    how to get the current scroll position from a container?

    I can get the current selected object with -

    psrec = WinSendDlgItemMsg( hwnd, ulCnrId,
    CM_QUERYRECORDEMPHASIS,
    MPFROMLONG( CMA_FIRST),
    MPFROMLONG( CRA_SELECTED));

    but how can I query the scroll position (and set it again afterwards
    when I filled it with refreshed objects)?

    Thanks, Andi


    ---
    Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lars Erdmann@21:1/5 to Lars Erdmann on Sat Nov 14 18:11:26 2015
    On 05.10.15 20.57, Lars Erdmann wrote:
    Test

    Andi B. schrieb:
    Lars Erdmann schrieb:
    Am 14.09.15 20.11, schrieb Andi B.:
    Hi,
    how to get the current scroll position from a container?

    I can get the current selected object with -

    psrec = WinSendDlgItemMsg( hwnd, ulCnrId,
    CM_QUERYRECORDEMPHASIS,
    MPFROMLONG( CMA_FIRST),
    MPFROMLONG( CRA_SELECTED));

    but how can I query the scroll position (and set it again afterwards
    when I filled it with refreshed objects)?

    Thanks, Andi


    ---
    Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)