Exemple #1
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            if (comboApp.SelectedIndex > -1)
            {
                try
                {
                    PosWindow.Rect position = new PosWindow.Rect
                    {
                        Left = Int32.Parse(textPosLeft.Text),
                        Top  = Int32.Parse(textPosTop.Text) //Int32.Parse(textPosRight.Text), Int32.Parse(textPosBottom.Text) };
                    };

                    String app = comboApp.SelectedItem.ToString();
                    if (Program.savedApps.ContainsKey(app))
                    {
                        Program.savedApps[app] = position;
                    }
                    else
                    {
                        Program.savedApps.Add(app, position);
                    }

                    IntPtr hWnd = PosWindow.FindWindow(null, comboApp.SelectedItem.ToString());
                    if (hWnd != IntPtr.Zero)
                    {
                        PosWindow.SetWindowPos(hWnd, IntPtr.Zero, position.Left, position.Top, 500, 500, PosWindow.SWP_NOSIZE | PosWindow.SWP_NOZORDER);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Please enter valid values");
                    return;
                }
            }
        }
Exemple #2
0
        public static void setPositions()
        {
            foreach (KeyValuePair<String, PosWindow.Rect> app in Program.savedApps)
            {

                IntPtr hWnd = PosWindow.FindWindow(null, app.Key);
                if (hWnd != IntPtr.Zero)
                {
                    PosWindow.SetWindowPos(hWnd, IntPtr.Zero, app.Value.Left, app.Value.Top, 0, 0, PosWindow.SWP_NOSIZE | PosWindow.SWP_NOZORDER);
                }
            }
        }