Note that the files and icons that you have on your desktop are still there, they just are not visible when you are viewing the desktop. The files and shortcuts that are there will still be accessible from within programs, files and folders, but they will no longer be visible when you are viewing your desktop. But rather than deleting or moving the files from the desktop, you can instead choose to hide icons on the Desktop. #Hide icons on desktop windows 7 installMany programs will also install shortcut icons on the desktop by default, in another effort to improve usability of their product.īut this can lead to a very crowded desktop, making it difficult to locate the files you want, or to see the picture that you have set as your background. Return (info.dwStyle & _VISIBLE) = desktop is one of the most frequently accessed locations for many Windows users, and people like to put shortcut icons and files there because it is easy to remember the location. In response to James M, this function returns the current state: bool IconsVisible() Now regardless of the desktop toggle or wallpaper rotation the ToggleDesktopIcons should always work.įor reference this is my toggle desktop function which caused the issue with the original ToggleDesktopIcons function static public void ToggleDesktop(object sender, EventArgs e) } while (hShellViewWin = IntPtr.Zero & hWorkerW != IntPtr.Zero) HShellViewWin = FindWindowEx(hWorkerW, IntPtr.Zero, "SHELLDLL_DefView", null) HWorkerW = FindWindowEx(hDesktopWnd, hWorkerW, "WorkerW", null) As there can be multiple WorkerW windows, iterate through all to get the correct one When this fails (picture rotation is turned ON, toggledesktop shell cmd used ), then look for the WorkerW windows list to get the HShellViewWin = FindWindowEx(hProgman, IntPtr.Zero, "SHELLDLL_DefView", null) Get and load the main List view window containing the icons. If the main Program Manager window is found Var hProgman = FindWindow("Progman", "Program Manager") Static IntPtr GetDesktopSHELLDLL_DefView() Public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle) SendMessage(GetDesktopSHELLDLL_DefView(), WM_COMMAND, toggleDesktopCommand, IntPtr.Zero) Īnd add a GetDesktopSHELLDLL_DefView function: #Hide icons on desktop windows 7 how to(see WinApi - How to obtain SHELLDLL_DefView and Windows Desktop ListView Handle.īased on those and building upon Ondrej Balas's earlier answer change the ToggleDesktopIcons function to be : static void ToggleDesktopIcons() In both of these cases the SHELLDLL_DefView window, which is the recipient of the toggleDesktopCommand in the ToggleDesktopIcons function, is not a child of the "Program manager" window but of a 'WorkerW" window. #Hide icons on desktop windows 7 codeThe windows API code along with more information about the window styles can be found here: Įven though this is quite old when I tried Ondrej Balas's answer, one problem I found with this solution is that it does not work if the ToggleDesktop command is used to show the desktop ( also if wallpaper rotation is enabled ). Info.cbSize = (uint)Marshal.SizeOf(info) IntPtr hWnd = GetWindow(GetWindow(FindWindow("Progman", "Program Manager"), GetWindow_Cmd.GW_CHILD), GetWindow_Cmd.GW_CHILD) Here is a function that calls the above code and returns true if the window is visible, false if not. : this() // Allows automatic initialization of "cbSize" with "new WINDOWINFO(null/true/false)".ĬbSize = (UInt32)(Marshal.SizeOf(typeof(WINDOWINFO))) Private static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi) To test to see if icons are visible or not, you can query for the WS_VISIBLE style by using the GetWindowInfo function, shown below: "FolderView" is the actual window that contains the icons. This sends a message to the SHELLDLL_DefView child window of Progman, which tells it to toggle visibility (by adding or removing the WS_VISIBLE style) of it's only child, "FolderView". SendMessage(hWnd, WM_COMMAND, toggleDesktopCommand, IntPtr.Zero) IntPtr hWnd = GetWindow(FindWindow("Progman", "Program Manager"), GetWindow_Cmd.GW_CHILD) Var toggleDesktopCommand = new IntPtr(0x7402) static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam) static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd) static extern IntPtr FindWindow(string lpClassName, string lpWindowName) Here is sample code in C# that will toggle desktop icons.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |