Vista 工具栏如何忽略或找出边框填充设置?

发布于 2024-07-27 01:54:48 字数 845 浏览 4 评论 0原文

我有一个在旧版本 Windows 下开发的工具栏,由于窗口新边框填充,该工具栏在 Vista 下大部分被切断。 默认边框填充为 4 时,工具栏上的所有内容都会向右下方推四个像素,然后从底部和右侧裁剪所有内容四个像素。 我不太关心水平尺寸,但垂直尺寸意味着应用程序会丢失八个像素的可见内容。

我所说的“工具栏”是指创建的窗口类似于以下内容:

APPBARDATA  AppBarData;
AppBarData.hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, MAIN_WNDCLASS,
                                 "", WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN,
                                 0, 0, 400, TOOLBAR_HEIGHT, NULL, NULL,
                                 AppInstance, NULL);
// more initialization  ....
SHAppBarMessage(ABM_NEW, &AppBarData);

由于边框填充对于 Vista 来说似乎是一个新的配置项,那么在 XP 和 Vista 中运行的应用程序如何处理此问题? 我的问题是:

  1. 工具栏是否可以告诉 Vista“忽略‘边框填充’设置;我的边框填充为 0”?
  2. 如果不是,应用程序如何确定边框填充的设置,以便使其窗口高两倍?
  3. 对于这两个问题,如何以允许相同的可执行文件在 XP、Vista、Win2003 等下运行的方式做到这一点?

I have a toolbar developed under older versions of Windows that is largely cut off under Vista due to the window new border padding. With the default border padding of 4, the everything on the toolbar is shoved four pixels down and to the right, and then everything is cropped four pixels from the bottom and right sides. I don't really care about the horizontal dimension as much, but vertically this means the application loses eight pixels of visible content.

By "toolbar" I mean a window created similar to the following:

APPBARDATA  AppBarData;
AppBarData.hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, MAIN_WNDCLASS,
                                 "", WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN,
                                 0, 0, 400, TOOLBAR_HEIGHT, NULL, NULL,
                                 AppInstance, NULL);
// more initialization  ....
SHAppBarMessage(ABM_NEW, &AppBarData);

Since border padding is a configuration item seemingly new to Vista, how can an application that runs in both XP and Vista handle this? My questions are:

  1. Is it possible for a toolbar to tell Vista "Ignore the 'border padding' setting; my border padding is 0"?
  2. If not, how does an application figure out what the border padding is set to so it can make its window taller by twice that amount?
  3. For both questions, how do you do this in a way that allows the same executable to operate under XP, Vista, Win2003, and so on?

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

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

发布评论

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

评论(3

小矜持 2024-08-03 01:54:48

一种选择是使用不同的窗口样式,从 WS_THICKFRAME 开始。

要计算填充,请尝试使用 GetClientRect 和 GetWindowRect 并从另一个中减去一个。

one option is to play with different window styles, starting with WS_THICKFRAME.

to figure out the padding try using GetClientRect and GetWindowRect and subtract one from the other.

请恋爱 2024-08-03 01:54:48

另一件需要单独注意的事情是,如果您已经尝试使用 GetSystemMetrics 或类似方法来考虑窗口边框,则您编译的子系统会影响边框对客户区域的影响。

objectmix 上的链接试图解释这一点。 对于子系统,我相信它们的意思是链接 .exe 时的 /subsystem 标志,或 Visual Studio 中的相应设置。

〜珠宝

Another thing to note separately is that if you are already trying to take into account the window border by using GetSystemMetrics or similar, the subsystem you compile to makes a difference in how the borders impact your client area.

A link at objectmix tries to explain this. By subsystem, I believe what they mean is the /subsystem flag when you link the .exe, or the corresponding setting in Visual Studio.

~jewels

梦境 2024-08-03 01:54:48

好吧,我想通了,排序吧。 就我而言,问题的原因是在调用 CreateWindowEx() 时使用了 WS_THICKFRAME,而我不需要。 以前,此设置用于将工具栏中的所有内容垂直居中。 我猜想在 WinXP(经典视图)和更早版本下,WS_THICKFRAME 可以预见地在所有尺寸上添加 3 个像素的填充。

因此,我删除了该选项并更改了代码,将所有内容向下和向右移动三个像素。 现在,工具栏在 WinXP 和 Vista 下看起来相同,并且我没有烦人且不必要的(对于此工具栏)额外填充。

这并不能解决一般情况,但由于我的回答可能会帮助遇到此问题的其他人,所以我想我应该发布我的解决方案。 我希望这对其他人有帮助。

Well, I figured it out, sort if. In my case, the cause of the problem was use of WS_THICKFRAME when calling CreateWindowEx(), which I didn't need. This setting was used, previously, to center everything vertically in the toolbar. I guess under WinXP (classic view) and earlier, a WS_THICKFRAME predictably added 3 pixels of padding on all sizes.

Thus, I removed that option and changed the code to move everything three pixels down and to the right. Now the toolbar looks identical under WinXP and Vista and I don't have the annoying and unnecessary (for this toolbar) extra padding.

This doesn't solve the general case, but since my answer may help others who run into this, I thought I'd post my solution. I hope this helps someone else.

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