<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Windows Forms</title>
        <link>http://geekswithblogs.net/bullpit/category/9322.aspx</link>
        <description>Windows Forms</description>
        <language>en-US</language>
        <copyright>bullpit</copyright>
        <managingEditor>mayank_max@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Hiding a modal form and showing a new one minimizes parent window</title>
            <link>http://geekswithblogs.net/bullpit/archive/2008/12/22/hiding-a-modal-form-and-showing-a-new-one-minimizes.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;The scenario:&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
One main winform that is open all the time when the application starts. It has a menu strip at the top. User clicks on an item in menu strip and new modal window is opened which has more options. When the user clicks a button on this modal form, another modal form needs to be opened and the previous one to be hidden. Then when the user closes the current form, the previous form is displayed again. The main form has to be displayed all the time.&lt;/p&gt;
&lt;p&gt;Main form -&amp;gt; Menu item click -&amp;gt; open Modal form 1 -&amp;gt; button or any other item clicked on Model form 1 -&amp;gt; open Model form 2 and hide model form 1 -&amp;gt; user closed model form 2 and model form 1 shows up again.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The weird problem:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now the problem with this is that if any other window is maximized, be it Windows Exmplorer or the IDE or the Internet explorer, if I hide the second form and display the third form, the first form gets minimized...weird.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Workaround:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Bonnie and John posted very good solutions for this problem.&lt;/p&gt;
&lt;p&gt;Solution by Bonnie - Move the second form out of viewable screen and bring it back when the third form is closed.&lt;/p&gt;
&lt;p&gt; &lt;font face="Courier New"&gt;MySecondForm oForm = new MySecondForm();   &lt;br /&gt;
this.Location = new Point(this.Location.X, this.Location.Y - 5000);   &lt;br /&gt;
oForm.ShowDialog();   &lt;br /&gt;
this.Location = new Point(this.Location.X, this.Location.Y + 5000);   &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Solution by John - Use a timer:&lt;/p&gt;
&lt;p&gt; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;partial&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MainForm&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Form&lt;/span&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;  {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; MainForm()&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      InitializeComponent();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; button1_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      &lt;span style="COLOR: #2b91af"&gt;Form1&lt;/span&gt; frm1 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Form1&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      frm1.ShowDialog();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;  }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;  &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;partial&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Form1&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Form&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;  {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; Form1()&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      InitializeComponent();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; button1_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      &lt;span style="COLOR: #2b91af"&gt;Form2&lt;/span&gt; Frm2 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Form2&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      timer1.Start();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      Frm2.ShowDialog();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Show();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; timer1_Tick(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    {&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      timer1.Stop();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;      &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Hide();&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;    }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;  }&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;Heres the link for the thread:&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;font face="Arial"&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/e53437fb-b843-4361-8eff-783fb29ca761"&gt;http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/e53437fb-b843-4361-8eff-783fb29ca761&lt;/a&gt;#&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128120"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128120" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/bullpit/aggbug/128120.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>bullpit</dc:creator>
            <guid>http://geekswithblogs.net/bullpit/archive/2008/12/22/hiding-a-modal-form-and-showing-a-new-one-minimizes.aspx</guid>
            <pubDate>Tue, 23 Dec 2008 00:58:29 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/bullpit/comments/128120.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/bullpit/archive/2008/12/22/hiding-a-modal-form-and-showing-a-new-one-minimizes.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/bullpit/comments/commentRss/128120.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>