简体   繁体   English

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

[英]How to programmatically move windows taskbar (take two)

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中有一个类似的措辞问题,但它没有得到适当的回答,并且围绕它的大部分讨论落到了“你不应该这样做”。

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. 我目前正在使用c#,但这不是一个明确的要求,我可以很容易地实现从c ++或vb的转换,而p / invokes并不可怕。

The operating system is windows 7. 操作系统是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. [编辑:我已经尝试过SHAppBarMessage,使用SETPOS,它在Windows 7上不起作用。我尝试过MoveWindow和SetWindowPos pinvokes,也不能在任务栏上的Windows 7上运行。 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. 而且我确信我有正确的句柄,因为如果我使用ShowWindow pinvoke隐藏它,它真的隐藏了,虽然我不能回收未使用的空间用于其他任何东西。 These methods did work on XP, that is why its so frustrating.] 这些方法确实适用于XP,这就是它如此令人沮丧的原因。

Thank you very much for your time, Joao Correia 非常感谢你的时间,Joao Correia

Have you tried FindWindow() with Shell_TrayWnd as the class, and then use SetWindowPos to mvoe the window? 您是否尝试使用Shell_TrayWnd作为类的FindWindow(),然后使用SetWindowPos来窗口?

Not sure how Windows would take this though. 不知道Windows会如何采取这种方式。

There's also specific API to do with the AppBar's (what the taskbar is), check out: 还有与AppBar有关的特定API(任务栏是什么),请查看:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM