locked
CreateWindow scroll positioning RRS feed

  • Question

  • I've few questions related to the default scroll in a window. My window is created with the API CreateWindowEx called with WS_VSCROLL value set. My problems are..

    1. Scrollbar is always present even if nothing to scroll. I want the scroll bar to be displayed only if there is any scrollable items. As of now it displays the scrollbar always even if the contents in windows are fully visible.

    2. How to change the position of such default scroll bar position to left side. By default it display on right of the window.

    3. How to hide the bar of a scrollbar. I just want the up and down arrow of scrollbar to be displayed (and not the bar in between). Basically how to customize the position and other parameters of the default windows scrollbar that comes along with parent window creation.

    I want to achieve this with minimal changes in legacy code.

    Thanks

    Pervez

    Thursday, August 2, 2012 9:22 AM

Answers

  • 1. Scrollbar is always present even if nothing to scroll. I want the scroll bar to be displayed only if there is any scrollable items. As of now it displays the scrollbar always even if the contents in windows are fully visible.

    See the SetScrollRange or SetScrollInfo API.

    2. How to change the position of such default scroll bar position to left side. By default it display on right of the window.

    I don't know if you can.

    3. How to hide the bar of a scrollbar. I just want the up and down arrow of scrollbar to be displayed (and not the bar in between). Basically how to customize the position and other parameters of the default windows scrollbar that comes along with parent window creation.

    Again, I don't know if you can. Without the bar it's not really a
    scroll bar - just a couple of buttons.

    Dave

    • Proposed as answer by Jesse Jiang Monday, August 6, 2012 5:39 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 2:30 AM
    Thursday, August 2, 2012 11:23 AM
  • You have to do following things

    you need to place CScrollbar above the existing scrollbar. For this you need to adjust the Non-client area if your scroll bar is bigger than existing scrollbar.

    For modifiying the non client area you need to handle WM_NCCALCSIZE message

    See following samples.

    http://www.codeproject.com/Articles/14724/Replace-a-Window-s-Internal-Scrollbar-with-a-custo

    http://www.codeproject.com/Articles/1084/Custom-Scrollbar-Library-version-1-1


    Thanks, Renjith V R

    • Proposed as answer by Jesse Jiang Monday, August 6, 2012 5:40 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 2:30 AM
    Thursday, August 2, 2012 4:26 PM

All replies

  • 1. Scrollbar is always present even if nothing to scroll. I want the scroll bar to be displayed only if there is any scrollable items. As of now it displays the scrollbar always even if the contents in windows are fully visible.

    See the SetScrollRange or SetScrollInfo API.

    2. How to change the position of such default scroll bar position to left side. By default it display on right of the window.

    I don't know if you can.

    3. How to hide the bar of a scrollbar. I just want the up and down arrow of scrollbar to be displayed (and not the bar in between). Basically how to customize the position and other parameters of the default windows scrollbar that comes along with parent window creation.

    Again, I don't know if you can. Without the bar it's not really a
    scroll bar - just a couple of buttons.

    Dave

    • Proposed as answer by Jesse Jiang Monday, August 6, 2012 5:39 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 2:30 AM
    Thursday, August 2, 2012 11:23 AM
  • You have to do following things

    you need to place CScrollbar above the existing scrollbar. For this you need to adjust the Non-client area if your scroll bar is bigger than existing scrollbar.

    For modifiying the non client area you need to handle WM_NCCALCSIZE message

    See following samples.

    http://www.codeproject.com/Articles/14724/Replace-a-Window-s-Internal-Scrollbar-with-a-custo

    http://www.codeproject.com/Articles/1084/Custom-Scrollbar-Library-version-1-1


    Thanks, Renjith V R

    • Proposed as answer by Jesse Jiang Monday, August 6, 2012 5:40 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 2:30 AM
    Thursday, August 2, 2012 4:26 PM
  • Hi,

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, August 6, 2012 5:40 AM
  • Hi,

    I marked these replies as answer, if your issue have not been solved please unmark it and update more information about this issue.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, August 9, 2012 2:31 AM