Size problem
-
Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!
-
Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!
-
Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!
Hello, It looks like you are placing the size change code inside the constructor for the form. I'm not quite sure why that isn't working, but in an application I am working on, I have initial resizing done inside the
Load
event handler and it works perfectly. Try putting your sizing code inside theLoad
event handler instead and see if that works out. For example:private void FrmOne_Load(object sender, System.EventArgs e)
{
...
this.BackgroundImage = global::Project1.Properties.Resources.img_1;
this.ClientSize = this.BackgroundImage.Size;
...
}Hope that helps! Sincerely, Alexander Wiseman