コード例 #1
0
        private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            TaskTrayClass self = hwndDictionary.SingleOrDefault(a => a.Value.Handle == hwnd).Key;

            if (msg == WM_APP_TRAY && self != null)
            {
                const int WM_LBUTTONUP       = 0x0202;
                const int WM_RBUTTONUP       = 0x0205;
                const int NIN_BALLOONSHOW    = 0x0402;
                const int NIN_BALLOONHIDE    = 0x0403;
                const int NIN_BALLOONTIMEOUT = 0x0404;
                switch (lParam.ToInt32() & 0xFFFF)
                {
                case WM_LBUTTONUP:
                    if (self.targetWindow is ITaskTrayClickHandler)
                    {
                        ((ITaskTrayClickHandler)self.targetWindow).TaskTrayLeftClick();
                    }
                    break;

                case WM_RBUTTONUP:
                    if (self.targetWindow is ITaskTrayClickHandler)
                    {
                        ((ITaskTrayClickHandler)self.targetWindow).TaskTrayRightClick();
                    }
                    break;

                case NIN_BALLOONSHOW:
                    if (self.ForceHideBalloonTipSec > 0)
                    {
                        // 指定タイムアウトでバルーンチップを強制的に閉じる
                        if (self.balloonTimer == null)
                        {
                            self.balloonTimer       = new System.Windows.Threading.DispatcherTimer();
                            self.balloonTimer.Tick += (sender, e) =>
                            {
                                if (self.Visible)
                                {
                                    self.Visible = false;
                                    self.Visible = true;
                                }
                                self.balloonTimer.Stop();
                            };
                        }
                        self.balloonTimer.Interval = TimeSpan.FromSeconds(self.ForceHideBalloonTipSec);
                        self.balloonTimer.Start();
                    }
                    break;

                case NIN_BALLOONHIDE:
                case NIN_BALLOONTIMEOUT:
                    if (self.balloonTimer != null)
                    {
                        self.balloonTimer.Stop();
                    }
                    break;
                }
            }
            else if (msg == (int)CommonUtil.RegisterTaskbarCreatedWindowMessage() && self != null)
            {
                self.Visible = self.Visible;
            }
            return(IntPtr.Zero);
        }