SharpDevelop with Windows 8 and 10 classic apps on small devices
I’ve been playing with Windows 10 on my 7″ tablet and I’m quite liking it: it seems to have the best of Windows 8 with plenty of annoying things changed. I had a few teething problems with SharpDevelop, like getting the webcam to appear in a picture box, or responding properly to resize events. But they were solved simply by updating to version 5, so C# coding on Windows 10 seems to be going smoothly.
However, one of the problems with running modern versions of Windows on small tablets is Explorer insisting on opening classic app windows maximised. A lot of the time that’s fine as on such a small display it’s the easiest way to work. But there can be times when it’s a pain, like when my SharpDevelop code has a fixed size and layout, or even to have a small window in the corner of the screen that doesn’t block my view of other things.
Because of that I decided to adapt my code to give the same ‘normal-size’ windows whether I was working on my small tablet or larger laptop. Playing with my code I found that it can’t tell that it’s going to be maximised until the window is visible, so that means the form’s onload event can’t help. Of course, using the form’s shown event (which is triggered as soon as the window is visible) does provide an opportunity to resize the form, but it’s an ugly solution as the maximised window appears before suddenly getting smaller.
That led me on to this solution: in the SharpDevelop (or Visual Studio if you prefer) designer set the opacity of the form to 0% and add a Form.Shown event handler, then edit it to look like the code below. I know it’s not the most ideal way to do things, but I’m happy that my code now runs in a normal window on all sizes of Windows 8/10 screens :-)
void Form1Shown(object sender,EventArgs e) { this.WindowState=FormWindowState.Normal; this.Width=575; this.Height=476; this.Opacity=100; }












