I prefer set Taskbar to hide, but still want show clock all the time. I make a small clock (80x41px) lay at bottom-right corner of screen. I make it Topmost [edit: with Timer]:
我更喜欢将任务栏设置为隐藏,但仍然希望始终显示时钟。我在屏幕的右下角放了一个小时钟(80x41px)。我把它做到最顶层[编辑:带定时器]:
SetWindowPos(hwnd, HWND_TOPMOST, r.right - width, r.bottom - height, 0, 0, SWP_NOSIZE);
// r is my window's rect
When I click to TaskBar, my clock still on top of it. But when I play some fullscreen game it hide my clock. May be they use a special method.
My question is there is any way to show my window on top of every top-most window, even active top-most window? I don't need my app get keyboard or mouse input, just lay there to display time.
当我点击TaskBar时,我的时钟仍然在它上面。但是,当我玩一些全屏游戏时,它隐藏了我的时钟。可能是他们使用特殊方法。我的问题是,有没有办法在每个最顶层的窗口上显示我的窗口,甚至是活动的最顶层窗口?我不需要我的应用获取键盘或鼠标输入,只需躺在那里显示时间。
I know my question is quite specific as I write this clock for myself. I searched google but don't find any web pages can solve this (this question ask the same, but it want to get mouse event, and the answer say no, but I hope a window that doesn't need input maybe a special case).
Any help would be appreciated!
我知道我的问题非常具体,因为我为自己写这个时钟。我搜索谷歌,但没有发现任何网页可以解决这个问题(这个问题问同样,但它想得到鼠标事件,答案说不,但我希望一个不需要输入的窗口可能是一个特例)。任何帮助,将不胜感激!
Edit
Incase impossible, How about draw a rectangle on top of screen? As I don't need get input, this maybe a replace solution. Is that possible?
编辑Incase不可能,如何在屏幕上绘制一个矩形?由于我不需要输入,这可能是替代解决方案。那可能吗?
2 个解决方案
#1
It's not very elegant, but I've solved this before by constantly setting the window to HWND_TOPMOST
on a one-second timer.
它不是很优雅,但我之前通过在一秒计时器上不断设置窗口到HWND_TOPMOST来解决这个问题。
#2
Is it within the own process?
它在自己的过程中吗?
As a general rule, a process can only expect to set the foreground window if that process is already the foreground process. (Microsoft documents the restrictions in the SetForegroundWindow() MSDN entry.)
作为一般规则,如果该进程已经是前台进程,则进程只能设置前台窗口。 (Microsoft记录了SetForegroundWindow()MSDN条目中的限制。)
#1
It's not very elegant, but I've solved this before by constantly setting the window to HWND_TOPMOST
on a one-second timer.
它不是很优雅,但我之前通过在一秒计时器上不断设置窗口到HWND_TOPMOST来解决这个问题。
#2
Is it within the own process?
它在自己的过程中吗?
As a general rule, a process can only expect to set the foreground window if that process is already the foreground process. (Microsoft documents the restrictions in the SetForegroundWindow() MSDN entry.)
作为一般规则,如果该进程已经是前台进程,则进程只能设置前台窗口。 (Microsoft记录了SetForegroundWindow()MSDN条目中的限制。)