Пример #1
0
        public void Hide(IWin32Window windowToActivate)
        {
            this._windowToActivate = windowToActivate;
            _handleToActivate      = this._windowToActivate != null ? this._windowToActivate.Handle : IntPtr.Zero;

            if (this._minimumDuration > 0)
            {
                this._waitingForTimer = true;
                if (!this._minimumDurationComplete)
                {
                    return;
                }
            }

            if (this._hwnd != IntPtr.Zero)
            {
                APIMessage.PostMessage(this._hwnd, (int)WindowMessages.WM_CLOSE, (uint)IntPtr.Zero, (uint)IntPtr.Zero);
            }
        }
Пример #2
0
        private int SplashWindowProcedure(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            PAINTSTRUCT paintStruct;
            IntPtr      timerPtr;
            Graphics    graphics;

            if (msg <= (int)WindowMessages.WM_PAINT)
            {
                switch (msg)
                {
                case (int)WindowMessages.WM_CREATE:
                {
                    if (!this._transparencyKey.IsEmpty && this.IsLayeringSupported())
                    {
                        APIWindow.SetLayeredWindowAttributes(hwnd, (ulong)ColorTranslator.ToWin32(this._transparencyKey), (byte)0, LayeredWindowAttributesFlags.LWA_COLORKEY);
                    }

                    if (this._minimumDuration <= 0)
                    {
                        return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                    }

                    this._timer = APITimer.SetTimer(hwnd, 1, this._minimumDuration, (TIMERPROC)null);
                    return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                }

                case (int)WindowMessages.WM_DESTROY:
                {
                    APIMessage.PostQuitMessage(0);
                    return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
                }
                }

                if (msg == (int)WindowMessages.WM_PAINT)
                {
                    paintStruct = new PAINTSTRUCT();
                    timerPtr    = APIPainting.BeginPaint(hwnd, ref paintStruct);

                    if (timerPtr != IntPtr.Zero)
                    {
                        graphics = Graphics.FromHdcInternal(timerPtr);
                        graphics.DrawImage(this._image, 0, 0, this._width, this._height);

                        OnScreenCustomize(graphics);

                        graphics.Dispose();
                    }

                    APIPainting.EndPaint(hwnd, ref paintStruct);
                    return(0);
                }

                return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
            }

            if (msg == (int)WindowMessages.WM_ERASEBKGND)
            {
                return(1);
            }

            if (msg == (int)WindowMessages.WM_TIMER)
            {
                APITimer.KillTimer(hwnd, this._timer);
                this._timer = 0;
                this._minimumDurationComplete = true;

                if (this._waitingForTimer)
                {
                    APIMessage.PostMessage(hwnd, (int)WindowMessages.WM_CLOSE, (uint)IntPtr.Zero, (uint)IntPtr.Zero);
                }

                return(0);
            }

            return(APIWindow.DefWindowProc(hwnd, msg, wParam, lParam));
        }