I have created a simple test form with FormBorderStyle = FixedToolWindow by default and added a piece of code to the form DoubleClick event that will switch between FixedToolWindow and SizableToolWindow.
Switching the FormBorderStyle between these two seems to produce a weird effect that's causing a lot of issues on my application. The problem is that the window seems to change size and I can't have that. I just want to change the border, I need the form size to remain the same.
How can I fix this behavior? And by "fix", I mean, prevent this from happening if possible. I want to be able to specify my form size and to remain like that, no matter the type of border style.
Also, a solution by subclassing the Form class would be the perfect solution for me in case anyone as any ideas to solve this problem with such a method.
Question
ProclaimDragon
I have created a simple test form with FormBorderStyle = FixedToolWindow by default and added a piece of code to the form DoubleClick event that will switch between FixedToolWindow and SizableToolWindow.
Switching the FormBorderStyle between these two seems to produce a weird effect that's causing a lot of issues on my application. The problem is that the window seems to change size and I can't have that. I just want to change the border, I need the form size to remain the same.
For instance, here's the event code:
private void Settings_DoubleClick(object sender, System.EventArgs e) { if(FormBorderStyle == FormBorderStyle.FixedToolWindow) { System.Diagnostics.Debug.WriteLine("SWITCHING: FIXED -> SIZABLE"); FormBorderStyle = FormBorderStyle.SizableToolWindow; } else { System.Diagnostics.Debug.WriteLine("SWITCHING: SIZABLE -> FIXED"); FormBorderStyle = FormBorderStyle.FixedToolWindow; } }And to debug I use this:
private void Settings_SizeChanged(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine(this.Size); }And here's the output when I double click:
SWITCHING: FIXED -> SIZABLE {Width=373, Height=169} {Width=383, Height=179} SWITCHING: SIZABLE -> FIXED {Width=383, Height=179} {Width=373, Height=169}How can I fix this behavior? And by "fix", I mean, prevent this from happening if possible. I want to be able to specify my form size and to remain like that, no matter the type of border style.
Also, a solution by subclassing the Form class would be the perfect solution for me in case anyone as any ideas to solve this problem with such a method.
Link to comment
Share on other sites
7 answers to this question
Recommended Posts