Exemplo n.º 1
0
        public static void Main()
        {
            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok)
            {
                // Another instance is already running.
                return;
            }
            #endregion

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            }
            else
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");
            }

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            #region old code
            //if (!SingleInstanceCheck())
            //{
            //    return;
            //}

            // Causes crash?
            // If framework is not correct version then quit.
            //if (!FrameworkCheck())
            //{
            //    return;
            //}
            #endregion

            InitializeParentWindow();

            App app = new App();

            MenuBarWindow = new MenuBar()
            {
                Owner = _parentWindow
            };
            MenuBarWindow.Show();
            app.MainWindow = MenuBarWindow;

#if (ENABLEFIRSTRUN)
            FirstRun(app);
#endif

            /*if (Properties.Settings.Default.EnableDesktop)
             * {
             *  //DesktopWindow = new Desktop() { Owner = _parentWindow };
             *  DesktopWindow = new Desktop() {};
             *  DesktopWindow.Show();
             *  WindowInteropHelper f = new WindowInteropHelper(DesktopWindow);
             *  int result = NativeMethods.SetShellWindow(f.Handle);
             *  DesktopWindow.ShowWindowBottomMost(f.Handle);
             * }*/

            Int32 TOPMOST_FLAGS = 0x0001 | 0x0002;
            WindowInteropHelper menuBarHelper = new WindowInteropHelper(MenuBarWindow);
            MenuBarPtr = menuBarHelper.Handle;
            NativeMethods.SetWindowPos(menuBarHelper.Handle, (IntPtr)NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);

            CairoDesktop.NativeWindowEx _HookWin = new CairoDesktop.NativeWindowEx();
            _HookWin.CreateHandle(new System.Windows.Forms.CreateParams());
            NativeMethods.SetTaskmanWindow(_HookWin.Handle);
            NativeMethods.RegisterShellHookWindow(_HookWin.Handle);
            WM_SHELLHOOKMESSAGE = NativeMethods.RegisterWindowMessage("SHELLHOOK");

            Sound = new CairoDesktop.Sound.SoundAPI();
            Sound.Initialize(_HookWin.Handle);

            _HookWin.MessageReceived += ShellWinProc;

            //'Assume no error occurred

            app.Run();
        }
Exemplo n.º 2
0
        public static void Main()
        {
            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok)
            {
                // Another instance is already running.
                return;
            }
            #endregion

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            else
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            #region old code
            //if (!SingleInstanceCheck())
            //{
            //    return;
            //}

            // Causes crash?
            // If framework is not correct version then quit.
            //if (!FrameworkCheck())
            //{
            //    return;
            //}
            #endregion

            InitializeParentWindow();

            App app = new App();

            MenuBarWindow = new MenuBar() { Owner = _parentWindow };
            MenuBarWindow.Show();
            app.MainWindow = MenuBarWindow;

            #if (ENABLEFIRSTRUN)
            FirstRun(app);
            #endif

            /*if (Properties.Settings.Default.EnableDesktop)
            {
                //DesktopWindow = new Desktop() { Owner = _parentWindow };
                DesktopWindow = new Desktop() {};
                DesktopWindow.Show();
                WindowInteropHelper f = new WindowInteropHelper(DesktopWindow);
                int result = NativeMethods.SetShellWindow(f.Handle);
                DesktopWindow.ShowWindowBottomMost(f.Handle);
            }*/

            Int32 TOPMOST_FLAGS = 0x0001 | 0x0002;
            WindowInteropHelper menuBarHelper = new WindowInteropHelper (MenuBarWindow);
            MenuBarPtr = menuBarHelper.Handle;
            NativeMethods.SetWindowPos (menuBarHelper.Handle, (IntPtr)NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);

            CairoDesktop.NativeWindowEx _HookWin = new CairoDesktop.NativeWindowEx();
            _HookWin.CreateHandle (new System.Windows.Forms.CreateParams ());
            NativeMethods.SetTaskmanWindow (_HookWin.Handle);
            NativeMethods.RegisterShellHookWindow(_HookWin.Handle);
            WM_SHELLHOOKMESSAGE = NativeMethods.RegisterWindowMessage("SHELLHOOK");

            Sound = new CairoDesktop.Sound.SoundAPI();
            Sound.Initialize(_HookWin.Handle);

            _HookWin.MessageReceived += ShellWinProc;

            //'Assume no error occurred

            app.Run();
        }