简体   繁体   中英

Activate desktop on press of WIN+D

I am working on windows form application containing two forms. One gets hidden on click of other. Only one form is visible at a time. I have disabled the Win+D keys for both of them. Used following code for that

ntPtr hprog = NativeMethods.FindWindowEx(NativeMethods.FindWindowEx(NativeMethods.FindWindow("Progman", "Program Manager"),
IntPtr.Zero, "SHELLDLL_DefView", ""),
IntPtr.Zero, "SysListView32", "FolderView");
NativeMethods.SetWindowLong(this.Handle, GWL_HWNDPARENT, hprog);

But when I press Win+D the desktop gets disabled , to activate the desktop I need to press Win+D once more. This is happening for both the forms. Can you justify the cause of this? I need the desktop active all the time whether the form is opened or closed. This is happening on some PCs only not on all PCs. I am working on Windows 7 and Dot NEt 4.0.

This is probably not a practice you want to get in the habit of. A very large number of users use the windows key shortcuts and I do not mean just the computer savy. My wife is a nurse and she uses some of them.

You are trying to change the default behavior of windows for everyone who uses your app and this is only a good idea when you are creating native apps for "locked down" systems. If the environment doesn't allow the use of the windows key shortcuts then you can change them.

Trying to force users to do things is never the right idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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