0

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]:

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.

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?

Community
  • 1
  • 1
NoName
  • 7,940
  • 13
  • 56
  • 108
  • 1
    I use a clock called ClockX. It does a very good job but Windows (or maybe just Explorer) has some bugs its topmost handling. Usually when that clock disappears it suffices to right click on its system tray icon. But sometimes Explorer puts itself under other windows. Then, Windows-key + D to hide all windows and ditto to get them back. Anyway, beware that you're up against a number of bugs in windows. MIght complicate testing. – Cheers and hth. - Alf May 11 '15 at 09:46
  • 1
    There is no API to do this. Consider that if there was, other applications would use it and you would be back with the same problem. See http://blogs.msdn.com/b/oldnewthing/archive/2011/03/10/10138969.aspx – Richard Critten May 11 '15 at 10:02

2 Answers2

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.

RichieHindle
  • 272,464
  • 47
  • 358
  • 399
  • I'm doing it now so I can place it on top of taskbar. But some game use special method that it by pass this. – NoName May 11 '15 at 10:16
0

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.)

Hans
  • 269
  • 4
  • 14