windows 当我的应用程序最大化时不出现自动隐藏任务栏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/137005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Auto-Hide taskbar not appearing when my application is maximized
提问by Steve
My application draws all its own window borders and decorations. It works fine with Windows taskbars that are set to auto-hide, except when my application window is maximized. The taskbar won't "roll up". It will behave normally if I have the application not maximized, even when sized all the way to the bottom of the screen. It even works normally if I just resize the window to take up the entire display (as though it was maximized).
我的应用程序绘制了所有自己的窗口边框和装饰。它适用于设置为自动隐藏的 Windows 任务栏,除非我的应用程序窗口最大化。任务栏不会“卷起”。如果我没有最大化应用程序,它会正常运行,即使大小一直到屏幕底部也是如此。如果我只是调整窗口大小以占据整个显示器(就像它被最大化一样),它甚至可以正常工作。
回答by Steve
I found the problem. My application was handling the WM_GETMINMAXINFO message, and was overriding the values in the parameter MINMAXINFO record. The values that were in the record were inflated by 7 (border width) the screen pixel resolution. That makes sense in that when maximized, it pushes the borders of the window beyond the visible part of the screen. It also set the ptMaxPosition (point that the window origin is set to when maximized) to -7, -7. My application was setting that to 0,0, and the max height and width to exactly the screen resolution size (not inflated). Not sure why this was done; it was written by a predecessor. If I comment out that code and don't modify the MINMAXINFO structure, the Auto-hide works.
我发现了问题。我的应用程序正在处理 WM_GETMINMAXINFO 消息,并覆盖参数 MINMAXINFO 记录中的值。记录中的值增加了 7(边框宽度)屏幕像素分辨率。这是有道理的,因为当最大化时,它会将窗口的边界推到屏幕的可见部分之外。它还将 ptMaxPosition(最大化时窗口原点设置的点)设置为 -7、-7。我的应用程序将其设置为 0,0,并将最大高度和宽度设置为屏幕分辨率大小(未膨胀)。不知道为什么这样做;是前辈写的。如果我注释掉该代码并且不修改 MINMAXINFO 结构,则自动隐藏工作。
As to why, I'm not entirely sure. It's possible that the detection for popping up an "autohidden" taskbar is hooked into the mechanism for handling WM_MOUSEMOVE messages, and not for WM_NCMOUSEMOVE. With my application causing the maximize to park my border right on the bottom of the screen, I would have been generating WM_NCMOUSEMOVE events; with the MINMAXINFO left alone, I would have been generating WM_MOUSEMOVE.
至于为什么,我不完全确定。弹出“自动隐藏”任务栏的检测可能与处理 WM_MOUSEMOVE 消息的机制有关,而不是 WM_NCMOUSEMOVE。由于我的应用程序导致最大化将我的边框停在屏幕底部,我本来会生成 WM_NCMOUSEMOVE 事件;如果不考虑 MINMAXINFO,我会生成 WM_MOUSEMOVE。
回答by Kev
This is dependant on whether 'Keep the taskbar on top of other windows' is checked on the taskbar properties. If it's checked then the taskbar will appear.
这取决于是否在任务栏属性上选中了“将任务栏保持在其他窗口之上”。如果选中,则会出现任务栏。
But don't be tempted to programmatically alter this setting on an end users machine just to suit your needs, it's considered rude and bad practice. Your app should fit whatever environment it gets deployed to.
但是不要试图以编程方式在最终用户机器上更改此设置以满足您的需要,这被认为是粗鲁和糟糕的做法。您的应用程序应该适合它部署到的任何环境。