Esempio n. 1
0
 private void putValues(Control control)
 {
     if (control.GetType() == typeof(ComboBox))
     {
         ComboBox box = (ComboBox)control;
         if (box.SelectedIndex > -1)
         {
             tmpName = box.SelectedItem.ToString();
             IntPtr hWnd = PosWindow.FindWindow(null, tmpName);
             if (hWnd != IntPtr.Zero)
             {
                 PosWindow.GetWindowRect(hWnd, ref tmpPosition);
             }
         }
     }
     else if (control.GetType() == typeof(TextBox))
     {
         TextBox box = (TextBox)control;
         switch (box.Name)
         {
             case "textPosTop":
                 box.Text = tmpPosition.Top.ToString();
                 break;
             case "textPosLeft":
                 box.Text = tmpPosition.Left.ToString();
                 break;
         }
     }
 }
Esempio n. 2
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;
                }
            }
        }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
 private void buttonLoad_Click(object sender, EventArgs e)
 {
     //IntPtr hWnd = PosWindow.FindWindow(comboApp.SelectedItem.ToString(),null);
     if (comboApp.SelectedIndex > -1)
     {
         IntPtr hWnd = PosWindow.FindWindow(null, comboApp.SelectedItem.ToString());
         if (hWnd != IntPtr.Zero)
         {
             //PosWindow.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, PosWindow.SWP_NOSIZE | PosWindow.SWP_NOZORDER);
             PosWindow.Rect position = new PosWindow.Rect();
             PosWindow.GetWindowRect(hWnd, ref position);
             textPosLeft.Text   = position.Left.ToString();
             textPosTop.Text    = position.Top.ToString();
             textPosRight.Text  = position.Right.ToString();
             textPosBottom.Text = position.Bottom.ToString();
         }
     }
     else
     {
         MessageBox.Show("Please select an application");
     }
 }