none
How to move a CScrollBar object? RRS feed

  • Question

  • I want to create a scroll bar in a nonstandard size and position in a child window. I need this to move with a size and move event of the window, either automatically or in response to size or move messages.  I can create it ok as a CScrollBar object, but I can't figure out how to move it once created.  How do I move this object, or should I use another method to create the scroll bar?

    WR Wilson

    Saturday, September 17, 2016 5:01 PM

Answers

  • If CScrollBar is one from MFC, then it can be moved using MoveWindow or SetWindowPos member functions. The coordinates and size of the related window, after detecting the move and size notifications, can be got using GetWindowRect (or GetClientRect, depending on circumstances).

    Otherwise, give more details about the problematic moments.

    • Marked as answer by WR Wilson Monday, September 26, 2016 1:40 PM
    Saturday, September 17, 2016 7:16 PM

All replies

  • If CScrollBar is one from MFC, then it can be moved using MoveWindow or SetWindowPos member functions. The coordinates and size of the related window, after detecting the move and size notifications, can be got using GetWindowRect (or GetClientRect, depending on circumstances).

    Otherwise, give more details about the problematic moments.

    • Marked as answer by WR Wilson Monday, September 26, 2016 1:40 PM
    Saturday, September 17, 2016 7:16 PM
  • Just for your info, I had tried that and many other things many times with no effect, and got myself totally confused.  However, once you replied, I told myself that this was correct, and I took a very close look at what I had done.  Turns out I had inadvertently created two different scroll bars with the same names except for an underscore in two different places.  One I had made visible, the other I had not.   I moved the invisible one all over Heck's Half acre. In the immortal words of Forest Gump "stupid is as stupid does". 

    Thanks for the rapid response


    WR Wilson

    • Proposed as answer by Hart Wang Monday, September 26, 2016 7:29 AM
    Monday, September 19, 2016 2:17 PM
  • Hi WR Wilson,

    Thank you for sharing your answer.

    if your question has been resolved, please mark the thread.

    Best Regards,

    Hart


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Monday, September 26, 2016 7:31 AM