-
Notifications
You must be signed in to change notification settings - Fork 992
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixed #6421 - do not exit the form when changing ShowInTaskbar property and re-creating handle * Add unit test * Add manual test to Form.ShowInTaskbar
- Loading branch information
roland5572
authored
Apr 18, 2022
1 parent
11bdca7
commit 93c7049
Showing
5 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/FormShowInTaskbar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Drawing; | ||
using System.Windows.Forms; | ||
|
||
namespace WinformsControlsTest | ||
{ | ||
public class FormShowInTaskbar : Form | ||
{ | ||
public FormShowInTaskbar() | ||
{ | ||
Width = 600; | ||
Height = 460; | ||
StartPosition = FormStartPosition.CenterScreen; | ||
|
||
var btnTest = new Button() | ||
{ | ||
Text = "Click here to open new Form", | ||
Location = new Point(10, 10), | ||
Height = 60, | ||
AutoSize = true, | ||
}; | ||
|
||
btnTest.Click += BtnTest_Click; | ||
Controls.Add(btnTest); | ||
} | ||
|
||
private void BtnTest_Click(object sender, EventArgs e) | ||
{ | ||
using var form = new Form() | ||
{ | ||
Width = 680, | ||
Height = 400, | ||
StartPosition = FormStartPosition.CenterScreen, | ||
}; | ||
|
||
var btnTest = new Button() | ||
{ | ||
Text = $"Click here to test ShowInTaskbar.{Environment.NewLine}If the test result is failed, this dialog will automatically close, or it will throw an exception.", | ||
Location = new Point(10, 10), | ||
Height = 60, | ||
AutoSize = true, | ||
}; | ||
|
||
btnTest.Click += (object sender, EventArgs e) => | ||
{ | ||
IntPtr formHandle = form.Handle; | ||
form.ShowInTaskbar = !form.ShowInTaskbar; | ||
|
||
if (form.IsHandleCreated == false) | ||
throw new Exception(); | ||
|
||
if (formHandle == form.Handle) | ||
throw new Exception(); | ||
}; | ||
|
||
form.Controls.Add(btnTest); | ||
form.ShowDialog(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters