I have a Windows Forms application that opens child forms. The forms are opened by calling Form.ShowDialog().
When the application is being executed on a tablet PC with Windows 11 then the child form always opens in maximized mode. This is not what I want.
How can I prevent the child forms being opened in maximized mode?
I have written a small sample application:
<code>namespace DialogSizeTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// This shows a dialog in "normal" size even on Panasonic Tablet with Windows 11.
var dlg = new OpenFileDialog();
dlg.ShowDialog(this);
}
private void button2_Click(object sender, EventArgs e)
{
// This shows a maximized dialog on Panasonic Tablet with Windows 11. Why?
var dlg = new MyOwnDialog();
dlg.ShowDialog(this);
}
}
}
</code>
<code>namespace DialogSizeTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// This shows a dialog in "normal" size even on Panasonic Tablet with Windows 11.
var dlg = new OpenFileDialog();
dlg.ShowDialog(this);
}
private void button2_Click(object sender, EventArgs e)
{
// This shows a maximized dialog on Panasonic Tablet with Windows 11. Why?
var dlg = new MyOwnDialog();
dlg.ShowDialog(this);
}
}
}
</code>
namespace DialogSizeTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// This shows a dialog in "normal" size even on Panasonic Tablet with Windows 11.
var dlg = new OpenFileDialog();
dlg.ShowDialog(this);
}
private void button2_Click(object sender, EventArgs e)
{
// This shows a maximized dialog on Panasonic Tablet with Windows 11. Why?
var dlg = new MyOwnDialog();
dlg.ShowDialog(this);
}
}
}
MyOwnDialg() is just a very simple Windows Form with one label on it.
I have used that application to test on the following configurations:
Test# | Hardware | Windows Version | Main Form Size | File Open Size | My Own Dialog Size |
---|---|---|---|---|---|
1 | Laptop | 11 | normal | normal | normal |
2 | Tablet PC | 10 (tablet mode on) | maximized | normal | normal |
3 | Tablet PC | 10 (tablet mode off) | normal | normal | normal |
4 | Tablet PC | 11 | maximized | normal | maximized |
Tests 1,2,3 have the results that I would expect.
Test 4 has an unexpected result! I would expect my own dialog to be normal size.