CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Smile 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.

  2. #2
    Join Date
    Oct 2009
    Posts
    2

    Re: Replacing the desktop instead of running in a window?

    It looks like I did it with the help of this link:

    http://social.msdn.microsoft.com/for...-2b4705064ce9/

    It seems to work. Here is the code (the language is F#):

    Code:
    
       let tWnd =
            let help = Interop.WindowInteropHelper mainWindow
            help.Handle
                   
       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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured