一种将 win32 窗口滚动条设置到左侧的方法?

发布于 2024-10-18 20:38:13 字数 123 浏览 4 评论 0原文

Win32 API中有没有一种方法可以将垂直滚动条的位置设置为窗口的左边框(可能是本机的)。

我查看了 WS 定义,只有 WS_EX_LEFTSCROLLBAR 但它适用于从右到左的文本。

先感谢您。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日浅笑〃 2024-10-25 20:38:13

有趣的。似乎文档会根据您查看的位置而有所不同。如果您查看“扩展窗口样式”,它会显示:

WS_EX_LEFTSCROLLBAR 将垂直滚动条放置在客户区的左侧。

但如果你看看 CreateWindowEx 下,它会说:

WS_EX_LEFTSCROLLBAR
如果 shell 语言是希伯来语、阿拉伯语或其他支持阅读顺序对齐的语言,则垂直滚动条(如果存在)位于客户区的左侧。对于其他语言,样式将被忽略。

所以我不知道官方的答案是什么。我确实在我的机器(Windows 7 Professional)上尝试过,滚动条出现在左侧。

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

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 );
记忆消瘦 2024-10-25 20:38:13

我使用此代码意外地对子类化列表视图执行了此操作。混淆了 windows 扩展样式和 listview 扩展样式。 LABELTIP 和 LEFTSCROLLBAR 具有相同的值。

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

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;
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文