Пример #1
0
        private void RegisterAppBar(bool registered)
        {
            APPBARDATA abd = new APPBARDATA();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = this.Handle;

            desktopHandle = APIWrapper.GetDesktopWindow();
            shellHandle   = APIWrapper.GetShellWindow();
            if (!registered)
            {
                //register
                uCallBackMsg         = APIWrapper.RegisterWindowMessage("APPBARMSG_MYSTARTUP");
                abd.uCallbackMessage = uCallBackMsg;
                uint ret = APIWrapper.SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);
            }
            else
            {
                APIWrapper.SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
            }
        }
Пример #2
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            if (m.Msg == uCallBackMsg)
            {
                switch (m.WParam.ToInt32())
                {
                case (int)ABNotify.ABN_FULLSCREENAPP:
                {
                    IntPtr hWnd = APIWrapper.GetForegroundWindow();
                    //判断当前全屏的应用是否是桌面
                    if (hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle))
                    {
                        RunningFullScreenApp = false;
                        break;
                    }
                    //判断是否全屏
                    if ((int)m.LParam == 1)
                    {
                        this.RunningFullScreenApp = true;
                    }
                    else
                    {
                        this.RunningFullScreenApp = false;
                    }
                    break;
                }

                default:
                    break;
                }
            }
            else if (m.Msg == WM_QUERYENDSESSION)
            {
                stopDateTime   = DateTime.Now;
                exitFlag       = true;
                systemShutdown = true;
            }

            base.WndProc(ref m);
        }