c# winform Press the shortcut key win+d, the program window is not hidden, does not affect the hidden window of other programs, and must always be displayed on the desktop, under other application windows, how to achieve this?
Asked
Active
Viewed 717 times
0
-
2what have you tried so far? – jazb Oct 18 '19 at 03:49
-
1Welcome to Stackoverflow. Your best bet is to show us what you've tried that isn't working. Additionally, your grammar makes it hard to understand exactly what you're looking for. – The Muffin Man Oct 18 '19 at 03:49
-
The OP want to have a winform on the desktop always shown even using the desktop hide all function. Usefull to display notes, system stats and so on. I don't know if it is possible... perhaps with some WinAPI... https://stackoverflow.com/questions/35217599/drawing-on-the-desktop-using-c-sharp – Oct 18 '19 at 04:58
-
Press the win+d shortcut to hide and not draw at the bottom: under other windows on the desktop – clh Oct 18 '19 at 05:37
-
Are you talking about _minimize to System Tray?_ – Oct 18 '19 at 05:41
-
I want to keep my window on the desktop. Under other application windows, I can't hide it, including pressing the system shortcut win+d. It is equivalent to another desktop on the desktop, not hidden. On the tray or taskbar – clh Oct 18 '19 at 05:46
-
You can try: your window gets a [WM_WINDOWPOSCHANGING](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-windowposchanging) (and a `WM_GETMINMAXINFO` before that) message when the System is about to minimize it (see the Remarks section there). The (`x, y`) values are negative when minimized. `lParam` contains the [WINDOWPOS](https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-windowpos?redirectedfrom=MSDN) struct that defines its new position (you can retrive it wih `var winPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));` in the `WndProc` override) and change it. – Jimi Oct 18 '19 at 06:21
-
How to stop hiding hidden messages in WndProc? Below is my code, it will still be hidden when the system key win+d is pressed: Protected override void WndProc(ref Message m) { If (m.Msg == 0x0046 || m.Msg == 0x0024) { WINDOWPOS winPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS)); If (winPos.cx <= 0) { this.WindowState = FormWindowState.Normal; } } base.WndProc(ref m); } – clh Oct 18 '19 at 07:02
-
You didn't read the Remaks section `WM_WINDOWPOSCHANGING` and *skipped* the last 3 words of my previous comment :) – Jimi Oct 18 '19 at 10:09
-
The value corresponding to this tag [WM_WINDOWPOSCHANGING] is [0x0046], and the value corresponding to the tag [WM_GETMINMAXINFO] is 0x0024. When intercepting this information in the WndProc method, you can see that the cx and cy attributes of the structure [WINDOWPOS] are negative. I modified the code to have no effect on the following: – clh Oct 18 '19 at 13:12
-
var winpos2 = new WINDOWPOS(); winpos2.cx = 100; winpos2.cy = 100; winpos2.flags = winPos.flags; winpos2.hwnd = winPos.hwnd; winpos2.hwndInsertAfter = winPos.hwndInsertAfter; winpos2.x = winPos.x; winpos2.y = winPos.y; Message mes = new Message(); mes.HWnd = m.HWnd; unsafe{ mes.LParam = new IntPtr((int)(&winpos2)); } mes.Msg = m.Msg; – clh Oct 18 '19 at 13:15
1 Answers
0
In Form Load event:
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
if you need something more powerfull, look at kiosk mode solutions for windows:

Oleg
- 3,580
- 1
- 7
- 12
-
The requirement is that you can't hide it by pressing the system shortcut key win+d, you must always display it on the desktop. – clh Oct 19 '19 at 00:09