Пример #1
0
        void tray_Click(object sender, EventArgs e)
        {
            NotifyIcon tray    = sender as NotifyIcon;
            window     wnd     = tray.Tag as window;
            string     strText = wnd.title;

            if (winapi.IsWindow(wnd.handle))
            {
                showwindow(wnd, false);
                //winapi.ShowWindow(wnd.handle, winapi.SW_SHOWNORMAL);
                winapi.SetForegroundWindow(wnd.handle);
            }
            else
            {
                // MessageBox.Show("Window does not exist");

                notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
            }
            notifyIcon1.BalloonTipTitle = "Tray Minimizer : Error while bringing window «" + strText + "» in the foreground : ";
            notifyIcon1.BalloonTipText  = "Window does not exist.";
            notifyIcon1.ShowBalloonTip(1000);

            tray.Click -= new EventHandler(tray_Click);
            tray.Dispose();
        }
Пример #2
0
 private void showwindow(window wnd, bool hide)
 {
     winapi.ShowWindow(wnd.handle, state(wnd, hide));
     if (!hide)
     {
         winapi.SetForegroundWindow(wnd.handle);
     }
 }
Пример #3
0
        void tray_Click(object sender, EventArgs e)
        {
            NotifyIcon tray = sender as NotifyIcon;
            window     wnd  = tray.Tag as window;

            if (winapi.IsWindow(wnd.handle))
            {
                showwindow(wnd, false);
            }
            //else MessageBox.Show("Window does not exist");
            tray.Click -= new EventHandler(tray_Click);
            tray.Dispose();
        }
Пример #4
0
        private int state(window wd, bool hide)
        {
            if (hide)
            {
                return(winapi.SW_HIDE);
            }

            if (wd.isminimzed)
            {
                return(winapi.SW_MINIMIZE);
            }

            if (wd.ismaximized)
            {
                return(winapi.SW_MAXIMIZE);
            }
            return(winapi.SW_SHOW);
        }
Пример #5
0
        //tlissak
        private void trayactive()
        {
            IntPtr hWnd = winapi.GetForegroundWindow();

            if (!winapi.IsWindowVisible(hWnd))
            {
                return;
            }
            StringBuilder title = new StringBuilder(256);

            winapi.GetWindowText(hWnd, title, 256);
            if (string.IsNullOrEmpty(title.ToString()) && set.IgnoreTitle)
            {
                return;
            }
            window wnd = new window(hWnd, title.ToString(), winapi.IsIconic(hWnd), winapi.IsZoomed(hWnd));

            processwindow(wnd);
        }
Пример #6
0
        private void processwindow(window wnd)
        {
            string path = pathfromhwnd(wnd.handle);

            System.Drawing.Icon icon = Iconfrompath(path);

            NotifyIcon tray = new NotifyIcon(this.components);

            tray.Icon    = icon == null ? Properties.Resources.exeicon : icon;
            tray.Visible = true;
            tray.Tag     = wnd;
            tray.Text    = wnd.title.Length >= 64 ? wnd.title.Substring(0, 63) : wnd.title;
            //MessageBox.Show(tray.Text);
            tray.Click += new EventHandler(tray_Click);
            if (this._disposing)
            {
                return;
            }
            showwindow(wnd, true);
        }
Пример #7
0
        private void processwindow(window pWnd)
        {
            window wnd;
            IntPtr parent = winapi.GetParent(pWnd.handle);

            if (parent != IntPtr.Zero)
            {
                if (!winapi.IsWindowVisible(parent))
                {
                    return;
                }
                StringBuilder title = new StringBuilder(256);
                winapi.GetWindowText(parent, title, 256);
                if (string.IsNullOrEmpty(title.ToString()) && set.IgnoreTitle)
                {
                    return;
                }
                wnd = new window(parent, title.ToString(), winapi.IsIconic(parent), winapi.IsZoomed(parent));
            }
            else
            {
                wnd = pWnd;
            }

            string path = pathfromhwnd(wnd.handle);

            System.Drawing.Icon icon = Iconfrompath(path);

            NotifyIcon tray = new NotifyIcon(this.components);

            tray.Icon    = icon == null ? Properties.Resources.exeicon : icon;
            tray.Visible = true;
            tray.Tag     = wnd;
            tray.Text    = wnd.title.Length > 64 ? wnd.title.Substring(0, 63) : wnd.title;
            tray.Click  += new EventHandler(tray_Click);

            showwindow(wnd, true);
        }
Пример #8
0
 private void showwindow(window wnd, bool hide)
 {
     //winapi.FlashWindow(wnd.handle, false);
     winapi.ShowWindow(wnd.handle, state(wnd, hide));
 }