C#でFormアプリケーションを作っています。
起動時に、Width = 1, Height = ディスプレイの高さ で表示させたいのですが、なぜかWidthが6になります。
なぜでしょうか。
クリックイベントでサイズを指定すると、ちゃんと指定したサイズになります。
C#
1using System; 2using System.Drawing; 3using System.Windows.Forms; 4//create started at 2018.09.14 5class sbf : Form{ 6 7 static void Main(){ 8 9 Application.Run(new sbf()); 10 } 11 12 public sbf(){ 13 14 this.FormBorderStyle = FormBorderStyle.None; 15 this.MinimumSize = new Size(1, 35); 16 Width = 1; 17 Height = Screen.PrimaryScreen.Bounds.Height; 18 Top = 0; 19 Left = Screen.PrimaryScreen.Bounds.Width - 1; 20 StartPosition = FormStartPosition.Manual; 21 BackColor = Color.Black; 22 23 this.Click += new EventHandler(Form_Click); 24 } 25 26 public void Form_Click(object sender, EventArgs e){ 27 28 Console.WriteLine("now: " + Width); 29 30 if(Width == 1){ 31 32 Width = 300; 33 Height = 35; 34 Top = 20; 35 Left = 0; 36 } else{ 37 38 Width = 1; 39 Height = Screen.PrimaryScreen.Bounds.Height; 40 Top = 0; 41 Left = Screen.PrimaryScreen.Bounds.Width - 1; 42 } 43 Console.WriteLine("next: " + Width); 44 } 45}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/14 03:53