<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Coeamyd's - Windows Forms</title>
    <link>http://www.coeamyd.net/</link>
    <description>...It ain't easy being green</description>
    <language>en-us</language>
    <copyright>Christoph Herold</copyright>
    <lastBuildDate>Wed, 30 Aug 2006 08:49:49 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>Christoph.Herold@coeamyd.net</managingEditor>
    <webMaster>Christoph.Herold@coeamyd.net</webMaster>
    <item>
      <trackback:ping>http://www.coeamyd.net/Trackback.aspx?guid=0dce2222-5323-4685-91e2-10dfa66a5b50</trackback:ping>
      <pingback:server>http://www.coeamyd.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.coeamyd.net/PermaLink,guid,0dce2222-5323-4685-91e2-10dfa66a5b50.aspx</pingback:target>
      <dc:creator>Christoph Herold</dc:creator>
      <wfw:comment>http://www.coeamyd.net/CommentView,guid,0dce2222-5323-4685-91e2-10dfa66a5b50.aspx</wfw:comment>
      <wfw:commentRss>http://www.coeamyd.net/SyndicationService.asmx/GetEntryCommentsRss?guid=0dce2222-5323-4685-91e2-10dfa66a5b50</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today I was wondering, how you are supposed to use the ToolStripContainer when you
want to build an MDI application. I found some solutions in forums speaking about
enumerating all controls and finding the MDIClient control, bringing it to the front,
and resizing it to match the size of the content panel. But I thought, this is quite
a workaround and can't be the way Microsoft meant for things to be done.
</p>
        <p>
A quick search actually ended with the explanation of how you should do it right.
There is an article in the msdn library containing a summary of the ToolStrip technology.
And in one paragraph, they actually tell you, that there is also a ToolStripPanel
component you can use on your form. This component is not present in the toolbox,
but you can activate it.
</p>
        <p>
So then you can simply drop as many ToolStripPanels onto your form, dock them accordingly,
and leave the content area free for the MDIClient.
</p>
        <p>
For reference: <a href="http://msdn2.microsoft.com/en-us/library/a5swc13h.aspx">http://msdn2.microsoft.com/en-us/library/a5swc13h.aspx</a></p>
        <img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=0dce2222-5323-4685-91e2-10dfa66a5b50" />
      </body>
      <title>ToolStripContainer and MDI</title>
      <guid isPermaLink="false">http://www.coeamyd.net/PermaLink,guid,0dce2222-5323-4685-91e2-10dfa66a5b50.aspx</guid>
      <link>http://www.coeamyd.net/PermaLink,guid,0dce2222-5323-4685-91e2-10dfa66a5b50.aspx</link>
      <pubDate>Wed, 30 Aug 2006 08:49:49 GMT</pubDate>
      <description>&lt;p&gt;
Today I was wondering, how you are supposed to use the ToolStripContainer when you
want to build an MDI application. I found some solutions in forums speaking about
enumerating all controls and finding the MDIClient control, bringing it to the front,
and resizing it to match the size of the content panel. But I thought, this is quite
a workaround and can't be the way Microsoft meant for things to be done.
&lt;/p&gt;
&lt;p&gt;
A quick search actually ended with the explanation of how you should do it right.
There is an article in the msdn library containing a summary of the ToolStrip technology.
And in one paragraph, they actually tell you, that there is also a ToolStripPanel
component you can use on your form. This component is not present in the toolbox,
but you can activate it.
&lt;/p&gt;
&lt;p&gt;
So then you can simply drop as many ToolStripPanels onto your form, dock them accordingly,
and leave the content area free for the MDIClient.
&lt;/p&gt;
&lt;p&gt;
For reference: &lt;a href="http://msdn2.microsoft.com/en-us/library/a5swc13h.aspx"&gt;http://msdn2.microsoft.com/en-us/library/a5swc13h.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=0dce2222-5323-4685-91e2-10dfa66a5b50" /&gt;</description>
      <comments>http://www.coeamyd.net/CommentView,guid,0dce2222-5323-4685-91e2-10dfa66a5b50.aspx</comments>
      <category>.NET;Development;Windows Forms</category>
    </item>
    <item>
      <trackback:ping>http://www.coeamyd.net/Trackback.aspx?guid=324a07fb-2572-4331-bee5-9d535328859d</trackback:ping>
      <pingback:server>http://www.coeamyd.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.coeamyd.net/PermaLink,guid,324a07fb-2572-4331-bee5-9d535328859d.aspx</pingback:target>
      <dc:creator>Christoph Herold</dc:creator>
      <wfw:comment>http://www.coeamyd.net/CommentView,guid,324a07fb-2572-4331-bee5-9d535328859d.aspx</wfw:comment>
      <wfw:commentRss>http://www.coeamyd.net/SyndicationService.asmx/GetEntryCommentsRss?guid=324a07fb-2572-4331-bee5-9d535328859d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sometimes, the developers of the .NET framework seem not to have thought things through.
This is also the case with the windows.forms namespace concerning the maximizing of
windows. When you have a fixed size dialog, you will probably also disable resizing
using the SizeGripStyle property. Furthermore, you'll want to disable the maximize
button, either by setting the MaximizeBox property to false, or by hiding the titlebar
controls altogether using the ControlBox property.
</p>
        <p>
This is all well, but I've noticed, that disabling all of these things doesn't disable
maximizing of windows completely. When you double-click the titlebar of the window,
you'll still be able to maximize it, probably making the contents of the form quite
ugly. If you REALLY want to disable maximizing, you'll have to handle some window
messages.
</p>
        <p>
This is actually not that difficult. All you have to do is override the WndProc method
and search for some constants in the windows API. What you'll need here are WM_SYSCOMMAND
and SC_MAXIMIZE, both found in winuser.h. Then all there's left to do is implement
the method as follows:
</p>
        <pre>    private const int WM_SYSCOMMAND = 0x0112;<br />
    private const int SC_MAXIMIZE = 0xF030;<br /><br />
    protected override void WndProc(ref Message m)<br />
    {<br />
        if (m.Msg == WM_SYSCOMMAND)<br />
        {<br />
            if (((int)m.WParam &amp; 0xFFF0) ==
SC_MAXIMIZE)<br />
            {<br />
                if (this.WindowState
!= FormWindowState.Normal)<br />
                {<br />
                    this.WindowState
= FormWindowState.Normal;<br />
                }<br />
                m.Result = new IntPtr(0);<br />
                return;<br />
            }<br />
        }<br />
        base.WndProc(ref m);<br />
    }</pre>
        <p>
That's it! You've now got a window, that WON'T MAXIMIZE.
</p>
        <p>
If you want a window, that can ONLY be maximized or minimized (as in there's no WindowState.Normal),
you will follow the same approach. But you'll find that in an article I wrote on codeproject.com
a while ago. If you want all the details, just read them here: <a href="http://www.codeproject.com/useritems/DisableNormalWindowState.asp">http://www.codeproject.com/useritems/DisableNormalWindowState.asp</a></p>
        <img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=324a07fb-2572-4331-bee5-9d535328859d" />
      </body>
      <title>Disabling Double-Click maximizing of windows</title>
      <guid isPermaLink="false">http://www.coeamyd.net/PermaLink,guid,324a07fb-2572-4331-bee5-9d535328859d.aspx</guid>
      <link>http://www.coeamyd.net/PermaLink,guid,324a07fb-2572-4331-bee5-9d535328859d.aspx</link>
      <pubDate>Thu, 30 Mar 2006 08:43:02 GMT</pubDate>
      <description>&lt;p&gt;
Sometimes, the developers of the .NET framework seem not to have thought things through.
This is also the case with the windows.forms namespace concerning the maximizing of
windows. When you have a fixed size dialog, you will probably also disable resizing
using the SizeGripStyle property. Furthermore, you'll want to disable the maximize
button, either by setting the MaximizeBox property to false, or by hiding the titlebar
controls altogether using the ControlBox property.
&lt;/p&gt;
&lt;p&gt;
This is all well, but I've noticed, that disabling all of these things doesn't disable
maximizing of windows completely. When you double-click the titlebar of the window,
you'll still be able to maximize it, probably making the contents of the form quite
ugly. If you REALLY want to disable maximizing, you'll have to handle some window
messages.
&lt;/p&gt;
&lt;p&gt;
This is actually not that difficult. All you have to do is override the WndProc method
and search for some constants in the windows API. What you'll need here are WM_SYSCOMMAND
and SC_MAXIMIZE, both found in winuser.h. Then all there's left to do is implement
the method as follows:
&lt;/p&gt;
&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private const int WM_SYSCOMMAND = 0x0112;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private const int SC_MAXIMIZE = 0xF030;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override void WndProc(ref Message m)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (m.Msg == WM_SYSCOMMAND)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if (((int)m.WParam &amp;amp; 0xFFF0) ==
SC_MAXIMIZE)&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if (this.WindowState
!= FormWindowState.Normal)&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; this.WindowState
= FormWindowState.Normal;&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; m.Result = new IntPtr(0);&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; return;&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; base.WndProc(ref m);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;p&gt;
That's it! You've now got a window, that WON'T MAXIMIZE.
&lt;/p&gt;
&lt;p&gt;
If you want a window, that can ONLY be maximized or minimized (as in there's no WindowState.Normal),
you will follow the same approach. But you'll find that in an article I wrote on codeproject.com
a while ago. If you want all the details, just read them here: &lt;a href="http://www.codeproject.com/useritems/DisableNormalWindowState.asp"&gt;http://www.codeproject.com/useritems/DisableNormalWindowState.asp&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=324a07fb-2572-4331-bee5-9d535328859d" /&gt;</description>
      <comments>http://www.coeamyd.net/CommentView,guid,324a07fb-2572-4331-bee5-9d535328859d.aspx</comments>
      <category>.NET;Development;Windows Forms</category>
    </item>
  </channel>
</rss>