CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    170

    Arrow Calculate scroll shift in pixels.

    Hi
    I have a listctrl with scrollbar. When user scroll i get message WM_HSCROLL. Now i want to know on how many pixels image is shifted. How can i calculate it?
    I need it to scroll another window with same scrollbar.So if i calculate shift i can use ScrollWindow.

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Calculate scroll shift in pixels.

    take a look at ::GetScrollBarInfo(...) it might help you.
    in the SCROLLBARINFO struct you have all the information about thr scrolling.

    if i helped dont forget to rate :-)
    Cheers

  3. #3
    Join Date
    May 2005
    Location
    Netherlands
    Posts
    187

    Re: Calculate scroll shift in pixels.

    Read the following article from MSDN
    Using scrollbars
    Have a look at the example in this article for scrolling a bitmap.

  4. #4
    Join Date
    Jun 2004
    Posts
    170

    Re: Calculate scroll shift in pixels.

    i have already read this articles. But us i understand each time programmer definr shift in pixels. In text shift relatively to text width,in bitmap to simply in pixels.


    And my question was how to determinate this values in pixels. If folow this articles it is imposible,am i right?

  5. #5
    Join Date
    May 2005
    Location
    Netherlands
    Posts
    187

    Re: Calculate scroll shift in pixels.

    I'm not sure I understand what you want.

    If you want to capture notifications for a scrollbar from a control you don't manage yourself (i.e. for which you can't SetScrollInfo to pixel units) this won't be possible, in general. Note that not every scroll action will result in actually scrolling the list contents a number of pixels. The link between scrollpos and the image is arbitrarily defined by the control designer.

  6. #6
    Join Date
    Jun 2004
    Posts
    170

    Re: Calculate scroll shift in pixels.

    It seems problem was solved.

    I calculate number of pixels on which i have to scroll.
    I take all window size(not only visible,but all) and all scrollbar range. And devide them. So i get number of pixel per scroll unit. Then i get number of step and multiply by pixel per step.

    One problem is then ScrollWindow need device units and i have pixels. Is ot the same?

  7. #7
    Join Date
    May 2005
    Location
    Netherlands
    Posts
    187

    Re: Calculate scroll shift in pixels.

    Quote Originally Posted by TOMNKZ
    One problem is then ScrollWindow need device units and i have pixels. Is ot the same?
    Same thing, only the origin point may differ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured