如何更改 win32 窗口的视口?

发布于 2024-10-11 05:15:06 字数 499 浏览 7 评论 0原文

我有一个窗口,里面有子窗口。子窗口占据大约 1000 像素的垂直空间。然而,我们的用户并不总是有 1000 像素的可用垂直空间 - 他们可能只有 500 或 600 像素。

我希望能够以 500 像素高的大小显示此窗口,并让用户上下“滚动”窗口以查看完整内容。窗口的高度应始终为 500 像素,但其中的视图应发生变化。

假设我可以在某处添加滚动条,以便用户可以选择他想要查看窗口的哪一部分。 Windows 通常会从高度 0 到高度 500 绘制窗口内容;例如,我如何告诉它“从高度 250 绘制到高度 750”?

我知道我可以使用 SetViewportOrgEx 等函数设置视口,但这些函数需要设备上下文 - 如果我希望它们“永久”,我什么时候调用它们?当我从 Windows 收到 WM_PAINT 消息时,我会调用它们吗?或者在其他时间?我想使用该系列的哪些功能?

编辑添加:我不想实际更改子窗口的位置 - 它们应该保持在相同的位置,唯一应该改变的是窗口的视图。

谢谢。

I have a window with child windows inside in it. The child windows take up about 1000 pixels of vertical space. However, our users don't always have 1000 pixels of vertical space available - they might have as little as 500 or 600 pixels.

I want to be able to display this window at a size of 500 pixels high, and have the user "scroll" up and down the window to see the full contents. The window should always be 500 pixels high, but the view within it should change.

Assume I can add a scroll bar somewhere so the user can choose which part of the window he wants to see. Windows will normally paint the window contents from height 0 to height 500; how do I tell it instead to "paint from height 250 to height 750", for example?

I know that I can set the viewport with functions like SetViewportOrgEx etc, but those functions require a device context - when do I call them if I want them to be "permanent"? Do I call them when I get the WM_PAINT message from windows? Or at some other time? And which functions from that family do I want to use?

Edit to add: I don't want to actually change the position of the child windows - they should stay at the same position, and the only thing that should change is the view into the window.

Thanks.

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

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

发布评论

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

评论(1

白日梦 2024-10-18 05:15:06

如果(当您收到有关滚动条更改的消息时)您使用 SW_SCROLLCHILDREN 标志调用 ScrollWindowEx,则应该告诉子窗口与其他所有内容一起滚动。这应该让他们处于正确的位置。

If (when you get messages about the scroll bars changing) you call ScrollWindowEx with the SW_SCROLLCHILDREN flag, the child windows should be told to scroll along with everything else. This ought to put them in the right position.

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