示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (File.Exists(LDataPath))
            {
                logger.Debug("Found Win32 POS Info.");
                WindowPlacement data = JsonConvert.DeserializeObject <WindowPlacement>(File.ReadAllText(LDataPath));
                var             hwnd = new WindowInteropHelper(this).Handle;
                data.length  = Marshal.SizeOf(typeof(WindowPlacement));
                data.flags   = 0;
                data.showCmd = (data.showCmd == (int)DISPLAY_MODE.SW_SHOW_MINIMIZED ? (int)DISPLAY_MODE.SW_SHOW_NORMAL : data.showCmd);
                WindowPlacementWin32.SetWindowPlacement(hwnd, ref data);
            }
            #region Desktop Widget Inner Gears
            if (attachToDesktop)
            {
                //Init();

                // The window is set to the parent, and the parent window of the background window is set to the Program Manager window.
                IntPtr hwnd2 = new WindowInteropHelper(this).Handle;
                //W32.SetParent(hwnd2, programIntPtr);


                //IntPtr pWnd = FindWindow("Progman", null);
                //pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefView", null);
                //pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null);
                //IntPtr tWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
                //SetParent(tWnd, pWnd);
                W32.EnumWindows((hwnd, lParam) =>
                {
                    var shell = W32.FindWindowEx(hwnd, IntPtr.Zero, "SHELLDLL_DefView", (IntPtr)null);
                    // Find the WorkerW that contains the SHELLDLL_DefView window handle
                    if (shell != IntPtr.Zero)
                    {
                        //hwnd is WorkerW
                        W32.SetParent(hwnd2, shell);
                        // Find the current WorkerW window, the next WorkerW window.
                        //IntPtr tempHwnd = W32.FindWindowEx(IntPtr.Zero, hwnd, "WorkerW", (IntPtr)null);

                        // hide this window
                        //W32.ShowWindow(tempHwnd, 0);
                    }

                    return(true);
                }, IntPtr.Zero);
            }
            #endregion


            EnterWidgetMode(null, null);
        }
示例#2
0
        private void EnterWidgetMode(object sender, RoutedEventArgs e)
        {
            // Sender is null if not invoked by user
            if (sender != null)
            {
                Console.WriteLine("Saving Widget Data...");

                WindowPlacement wp;
                var             hwnd = new WindowInteropHelper(this).Handle;
                WindowPlacementWin32.GetWindowPlacement(hwnd, out wp);
                var encoded = JsonConvert.SerializeObject(wp);
                File.WriteAllText(LDataPath, encoded);
            }

            this.ResizeMode       = ResizeMode.NoResize;
            WidgetMove.Visibility = Visibility.Hidden;
            WebView.Visibility    = Visibility.Visible;
        }