如何以编程方式移动 Windows 任务栏(需要两个)

发布于 2024-09-24 11:36:09 字数 754 浏览 5 评论 0 原文

首先,我知道 SO 中有一个类似措辞的问题,但它还没有得到正确的回答,并且围绕它的大多数讨论都落在“你不应该这样做”。

那么让我们从基础开始吧。为什么需要这个。

我在一家公司工作,该公司向我们的员工分发了几十台平板电脑上网本。如您所知,上网本的分辨率相对较低,因此屏幕空间非常非常重要。

当我们将上网本切换到平板电脑模式时,我们用它们来书写,而纵向模式则更舒适。问题是,当屏幕旋转时,任务栏保持在与横向相同的相对边缘上。如果它位于底部,则它会留在纵向的底部。但由于我们已经在横向的左边缘使用它,所以最终任务栏占据了可用屏幕的非常明显的百分比。

我已经准备好了用于监听分辨率更改事件的结构,并且它工作正常,但是我看到的所有有关将消息传递到任务栏窗口的示例最终都无法移动它。就好像它被强行忽略了一样。

有什么办法可以实现这一点吗?我目前正在使用c#,但这不是一个明确的要求,我可以轻松实现从c++或vb的转换,并且p/invokes并不可怕。

操作系统是windows 7。

[编辑:我已经尝试过SHAppBarMessage,使用SETPOS,它在windows 7上不起作用。我尝试过MoveWindow和SetWindowPos pinvokes,在任务栏上的windows 7上也不起作用。对于其他窗口,它工作得很好。我确信我有正确的句柄,因为如果我使用 ShowWindow pinvoke 来隐藏它,它确实会隐藏,尽管我无法回收未使用的空间用于其他任何东西。这些方法在 XP 上确实有效,这就是为什么它如此令人沮丧。]

非常感谢您的宝贵时间, 若奥·科雷亚

First of all, i know there is a similarly phrased question in SO, but it hasn't been answered properly, and most of the discussion around it fell unto the "you shouldn't be doing that".

So lets start by the basics. Why this is needed.

I work on a company that handed out a few dozen tablet netbooks to our workers. As you know, netbooks have a comparatively lower resolution, and screen real estate is very, very important.

When we rotate the netbooks into tablet mode, we use them for writing, and portrait mode is much more comfortable for that. The thing is, when the screen is rotated, the taskbar stays on the same relative edge as on landscape. If it was at the bottom, it stays at the bottom on portrait. But since we already use it on the left edge on landscape, we end up with the taskbar taking up a very noticeable percentage of the available screen.

I have already the structure in place for listening to resolution changes event, and its working properly, but all the samples i've seen regarding passing messages to the taskbar window ultimately fail to move it. It's like its being forcefully ignored.

Is there any way to achieve this? I'm currently using c#, but that is not a definite requirement, i can easily achieve the conversion from c++ or vb, and p/invokes are not scary.

The operating system is windows 7.

[Edit: I have already tried SHAppBarMessage, with SETPOS, it doesn't work on windows 7. I have tried MoveWindow and SetWindowPos pinvokes, also don't work on windows 7 on the taskbar. For other windows it works just fine. And i am sure i have the right handle, because if i use ShowWindow pinvoke to hide it, it really hides, although i can't reclaim the unused space for anything else. These methods did work on XP, that is why its so frustrating.]

Thank you very much for your time,
Joao Correia

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

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

发布评论

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

评论(1

一场信仰旅途 2024-10-01 11:36:09

您是否尝试过使用 Shell_TrayWnd 作为类的 FindWindow(),然后使用 SetWindowPos 来移动窗口?

但不确定 Windows 将如何处理这个问题。

还有与 AppBar 相关的特定 API(任务栏是什么),请查看:

http://bytes.com/topic/c-sharp/answers/247701-moving-windows-takbar

Have you tried FindWindow() with Shell_TrayWnd as the class, and then use SetWindowPos to mvoe the window?

Not sure how Windows would take this though.

There's also specific API to do with the AppBar's (what the taskbar is), check out:

http://bytes.com/topic/c-sharp/answers/247701-moving-windows-takbar

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