Пример #1
0
        private AppViewHandle spawnProc(AppView av)
        {
            AppViewHandle avh = new AppViewHandle();

            // Start the process

            if (String.IsNullOrWhiteSpace(av.appFile)) return avh;

            avh.settings = av;

            var psh = new ProcessStartInfo(av.appFile, av.appArgs);
            psh.WindowStyle = ProcessWindowStyle.Minimized;
            avh.process = new Process();
            avh.process.StartInfo = psh;
            avh.process.Start();
            avh.process.WaitForInputIdle();

            int retries = 0;
            while (retries<10)
            {
                switch (av.findWindowMethod)
                {
                    case FindWindowMethod.CaptionSearch:
                        avh.handle = User32.FindWindowByCaption(av.captionMatch);
                        break;
                    case FindWindowMethod.MainWindow:
                        avh.handle = avh.process.MainWindowHandle;
                        break;
                }
                if (avh.handle == IntPtr.Zero)
                {
                    Thread.Sleep(100);
                    retries++;
                }
                else break;
            }
            avh.panel = new Panel();
            avh.panel.BackColor = Color.FromArgb(av.background);
            avh.panel.Width = Width;
            avh.panel.Height = GetHeightFromPercent(avh.settings.coverPercent);
            avh.panel.Top = 0;
            avh.panel.Left = 0;
            avh.panel.Visible = false;
            this.Controls.Add(avh.panel);

            Thread.Sleep(av.initDelay);

            // Set the panel control as the application's parent
            User32.SetParent(avh.handle, avh.panel.Handle);

            // Maximize application
            if(av.needsMaximize)
                User32.SendMessage(avh.handle, 274, 61488, 0);

            // Set window style to no borders
            var lStyle = User32.GetWindowLong(avh.handle, User32.GWL_STYLE);
            lStyle &= ~(User32.WS_CAPTION | User32.WS_THICKFRAME | User32.WS_SYSMENU);
            User32.SetWindowLong(avh.handle, User32.GWL_STYLE, lStyle);

            int lExStyle = User32.GetWindowLong(avh.handle, User32.GWL_EXSTYLE);
            lExStyle &= ~(User32.WS_EX_DLGMODALFRAME | User32.WS_EX_CLIENTEDGE | User32.WS_EX_STATICEDGE);
            User32.SetWindowLong(avh.handle, User32.GWL_EXSTYLE, lExStyle);

            // Call pRedraw
            pRedraw(avh, av);

            return avh;
        }
Пример #2
0
        private void pRedraw(AppViewHandle avh, AppView av)
        {
            int swpFlags = User32.SWP_FRAMECHANGED | User32.SWP_NOZORDER;
            if (!av.needsMove) swpFlags |= User32.SWP_NOMOVE;
            if (!av.needsResize) swpFlags |= User32.SWP_NOSIZE;

            User32.SetWindowPos(avh.handle, IntPtr.Zero, 0, 0, screenBounds.Width, GetHeightFromPercent(av.coverPercent), swpFlags);
        }