How to avoid minimize on show desktop or peek desktop from an application.

Bhushan Kolhe 0 Reputation points
2024-12-06T18:42:36.9766667+00:00

Hi,

I am trying to create a desktop widget like application which need to be visible on desktop at all times. To hide it from taskbar and alt + tab menu I am using WS_EX_TOOLWINDOW window style.

The problem is the application is minimized when using Peek Desktop function or Win + D shortcut or Show desktop button.

What is the best way to avoid/handle this minimization?

Thanks in advance.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,699 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,804 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 46,191 Reputation points
    2024-12-06T19:21:01.4066667+00:00

    What is probably happening is that the desktop window is covering your window so you think it has been minimized. If you add WS_EX_TOPMOST to the window extended styles then the desktop won't cover it. See What is the difference between Minimize All and Show Desktop?


  2. RLWA32 46,191 Reputation points
    2024-12-12T15:51:20.7333333+00:00

    For what its worth I solved the problem by installing a WH_GETMESSAGE hook in the Explorer process. Spy++ (64-bit version) showed that an undocumented message (WM_USER+83) was posted to the Program Manager window available from the GetShellWindow function whenever Show Desktop/Show Open Windows was invoked regardless of the method used to invoke it. The hook procedure watches for this message and, when detected it posts a message back to the test application make its window topmost or not.

    For example,

    DeskHook

    Naturally, this is all implementation dependent and is not guaranteed to work on all Windows versions/builds. I tested on Win10 22H2 with all updates installed.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.