WPF application that claims desktop real estate similar to windows taskbar

断了今生、忘了曾经 提交于 2019-12-01 06:09:30

问题


I'm building a WPF application that is designed to act as a notification toolbar for sending messages to users of an enterprise software platform. It's a bar that is a specific height, stretching all the way across the bottom of the user's desktop, sitting directly above the Windows taskbar.

What I'd like to do is to have my application "claim" or "reserve" the space it takes up and not allow any applications to load behind it. For example, if you were to resize your windows taskbar and make it larger, it will move icons and shortcuts, and maximizing windows will only use the desktop area that is not already being used by the taskbar.

Any idea how this could be pulled off? It's already set to be the topmost item on the desktop, so that's not my question. Right now if you opened another app and maximized it, then the bottom X pixels will be hidden behind my toolbar application.

(Note that I've added Windows 7 and Windows XP tags - I'd love to be able to implement this functionality on WinXP and up, but if I'm not able to do so on a particular version or versions, I can come up with a workaround)


回答1:


These are called AppBars in Windows and you can use the SHAppBarMessage function to "dock" your window to a side of a monitor. Then other windows, when maximized, will not obscure the docked window.

Here's a link to a similar question that has more information, including a link to a CodeProject page that walks you through creating one.



来源:https://stackoverflow.com/questions/6804697/wpf-application-that-claims-desktop-real-estate-similar-to-windows-taskbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!