Search code examples
windowswinapiscrollbar

A way to set win32 window scrollbar to the left?


Is there a way in Win32 API to set the place of vertical scrollbar to the left border of the window(a native one maybe).

I've looked at the WS definition and there is only WS_EX_LEFTSCROLLBAR but its for right to left text.

Thank you in advance.


Solution

  • Interesting. It seems that the documentation varies depending on where you look. If you look under "Extended Window Styles", it says:

    WS_EX_LEFTSCROLLBAR Places a vertical scroll bar to the left of the client area.

    But if you look under CreateWindowEx, it says:

    WS_EX_LEFTSCROLLBAR If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.

    So I have no idea what the official answer is. I did try it on my machine (Windows 7 Professional) and the scrollbar appeared on the left.

    CreateWindowEx( WS_EX_LEFTSCROLLBAR,
                    (LPCTSTR)classAtom,
                    _T( "Test Window" ),
                    WS_VISIBLE | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    NULL,
                    NULL,
                    hInstance,
                    NULL );