Exemplo n.º 1
0
        private void createShellWindow()
        {
            if (Shell.IsCairoRunningAsShell)
            {
                // create native window; we must pass a native window to SetShellWindow
                ShellWindow = new NativeWindowEx();
                CreateParams cp = new CreateParams();
                cp.Style   |= (int)NativeMethods.WindowStyles.WS_VISIBLE;
                cp.Style   |= unchecked ((int)NativeMethods.WindowStyles.WS_POPUP);
                cp.ExStyle |= (int)NativeMethods.ExtendedWindowStyles.WS_EX_TOOLWINDOW;
                cp.Height   = SystemInformation.VirtualScreen.Height;
                cp.Width    = SystemInformation.VirtualScreen.Width;
                cp.X        = SystemInformation.VirtualScreen.Left;
                cp.Y        = SystemInformation.VirtualScreen.Top;

                ShellWindow.CreateHandle(cp);
                ShellWindow.MessageReceived += WndProc;

                if (NativeMethods.SetShellWindow(ShellWindow.Handle) == 1)
                {
                    // we did it
                    isShellWindow = true;
                    CairoLogger.Instance.Debug("DesktopManager: Successfully set as shell window");
                }
            }
        }
Exemplo n.º 2
0
        internal void Initialize()
        {
            if (IsInitialized)
            {
                return;
            }

            try
            {
                ShellLogger.Debug("TasksService: Starting");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE         = RegisterWindowMessage("SHELLHOOK");
                WM_TASKBARCREATEDMESSAGE    = RegisterWindowMessage("TaskbarCreated");
                TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated");
                _HookWin.MessageReceived   += ShellWinProc;

                if (EnvironmentHelper.IsWindows8OrBetter)
                {
                    // set event hook for uncloak events
                    uncloakEventProc = UncloakEventCallback;

                    if (uncloakEventHook == IntPtr.Zero)
                    {
                        uncloakEventHook = SetWinEventHook(
                            EVENT_OBJECT_UNCLOAKED,
                            EVENT_OBJECT_UNCLOAKED,
                            IntPtr.Zero,
                            uncloakEventProc,
                            0,
                            0,
                            WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
                    }
                }

                // set window for ITaskbarList
                setTaskbarListHwnd(_HookWin.Handle);

                // adjust minimize animation
                SetMinimizedMetrics();

                // enumerate windows already opened and set active window
                getInitialWindows();

                IsInitialized = true;
            }
            catch (Exception ex)
            {
                ShellLogger.Info("TasksService: Unable to start: " + ex.Message);
            }
        }