C# Başka Bir Programın Boyutunu Değiştirme

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Uzman Üye
Katılım
6 Mar 2016
Mesajlar
187
Tepki puanı
24
Ödüller
7
10 HİZMET YILI
Gerekenler:2 Adet TextBox 1 Adet Button Son Olarak Beyin + Biraz C# Bilgisi
Kod
C#:
//lazım
using System.Diagnostics;
using System.Runtime.InteropServices;
//dll importlarımız
        [DllImport("user32.dll", SetLastError = true)]
        static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect);

        [DllImport("user32.dll", SetLastError = true)]
        static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int Width, int Height, bool Repaint);

        [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {
            public int left;
            public int top;
            public int right;
            public int bottom;
        }
// butona yazılacak kod
        private void button1_Click(object sender, EventArgs e)
        {
// bu eğer hiçbişey yazmazlarsa programın hata vermesini engellemek için
            if (String.IsNullOrEmpty(textBox2.Text) || String.IsNullOrWhiteSpace(textBox2.Text))
            {
                textBox2.Text = ("1000");
            }
            if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrWhiteSpace(textBox1.Text))
            {
                textBox1.Text = ("1000");
            }

            int i = Convert.ToInt32(textBox1.Text);
            int a = Convert.ToInt32(textBox2.Text);

            Process[] processes = Process.GetProcessesByName("Programın İsmi");
            foreach (Process p in processes)
            {
                IntPtr handle = p.MainWindowHandle;
                RECT Rect = new RECT();
                if (GetWindowRect(handle, ref Rect))
                    MoveWindow(handle, Rect.left, Rect.top, i, a, true);
            }

        }

Ayrıca Textboxlara Sayı Dışında Bişey Yazmayı Engellemek İçin Events Kısmından KeyPresslerine Şunları Yazın
Kod:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
    (e.KeyChar != '.'))
            {
                e.Handled = true;
            }

            // only allow one decimal point
            if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
            {
                e.Handled = true;
            }
 
Son düzenleme:
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst