On this page
This site
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Christoph Herold

ToolStripContainer and MDI#

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.

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.

So then you can simply drop as many ToolStripPanels onto your form, dock them accordingly, and leave the content area free for the MDIClient.

For reference: http://msdn2.microsoft.com/en-us/library/a5swc13h.aspx

Wednesday, August 30, 2006 9:49:49 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Disabling Double-Click maximizing of windows#

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.

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.

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:

    private const int WM_SYSCOMMAND = 0x0112;
    private const int SC_MAXIMIZE = 0xF030;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_SYSCOMMAND)
        {
            if (((int)m.WParam & 0xFFF0) == SC_MAXIMIZE)
            {
                if (this.WindowState != FormWindowState.Normal)
                {
                    this.WindowState = FormWindowState.Normal;
                }
                m.Result = new IntPtr(0);
                return;
            }
        }
        base.WndProc(ref m);
    }

That's it! You've now got a window, that WON'T MAXIMIZE.

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: http://www.codeproject.com/useritems/DisableNormalWindowState.asp

Thursday, March 30, 2006 9:43:02 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

All content © 2008 , Christoph Herold