October 10th, 2009, 02:55 AM
Replacing the desktop instead of running in a window?
Hello, I have a WPF application which runs in a Window. I would like to change that and have it replace the Windows desktop (this makes sense since the application is a file manager, among other things.).
I am in need of some generic explanation of how to do that because I have no clue if it's possible and how. So far I only understand that I'll probably have to call some Win32 functions. I am imagining something like "take the hwnd H of your wpf window, call GetDesktopWindow() as W, take the parent P of W, and replace H as the child of P". (This is what I seem to understand that I probably have to do, but I may be completely wrong. For example, I may need to implement some COM interfaces or create shell extensions.).
Currently I am browsing the source code of some "shell replacements" like geoshell, but I still can't locate the piece of code which replaces the desktop, and I am not sure this would apply to a WPF application anyway. So, I would be very grateful if somebody pointed at the right direction. Thank you very much for any pointers.
October 10th, 2009, 07:53 AM
Re: Replacing the desktop instead of running in a window?
It looks like I did it with the help of this link:
It seems to work. Here is the code (the language is F#):
let tWnd =
let help = Interop.WindowInteropHelper mainWindow
mainWindow.ResizeMode <- ResizeMode.NoResize //mainWindow has type System.Windows.Window
mainWindow.WindowStyle <- WindowStyle.None
let mutable pWnd = FindWindow("Progman", null)
pWnd <- FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null)
pWnd <- FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null)
SetParent(tWnd, pWnd) |> ignore
mainWindow.WindowState <- WindowState.Maximized
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.