ilcredo
ilcredo

Reputation: 795

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.

Upvotes: 0

Views: 1020

Answers (2)

user25130859
user25130859

Reputation: 1

I did it accidentally to a subclassed listview with this code. Had confused windows extended styles for listview extended styles. LABELTIP and LEFTSCROLLBAR have the same value.

protected override CreateParams CreateParams
    {
        get
        {
            CreateParams CP = base.CreateParams;

            CP.ExStyle |= // <-- WINDOW extended styles not ListView extended styles
                (int)
                (
                        APIsEnums.ListViewExtendedStyles.INFOTIP
                    | APIsEnums.ListViewExtendedStyles.LABELTIP // == WS_EX_LEFTSCROLLBAR 0x04000
                    | APIsEnums.ListViewExtendedStyles.DOUBLEBUFFER
                );

            return CP;
        }
    }

Upvotes: -1

Peter Ruderman
Peter Ruderman

Reputation: 12485

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 );

Upvotes: 1

Related Questions