2004-04-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / StatusBar.cs
index fe12034a8a6b5eca6a3ee3e47746f09ed656b8b2..589f9e923c496d0645ac336279e95ad7f9cda32e 100644 (file)
@@ -7,7 +7,7 @@
 //   Dennis Hayes (dennish@Raytek.com)
 //   Aleksey Ryabchuk (ryabchuk@yahoo.com)
 //
-// (C) 2002 Ximian, Inc
+// (C) 2002/3 Ximian, Inc
 //
 
 using System;
@@ -37,7 +37,7 @@ namespace System.Windows.Forms {
                        Dock = DockStyle.Bottom;
                        showPanels = false;
                        sizingGrip = true;
-                       Size = DefaultSize;
+                       base.TabStop = false;
                }
 
                public override string ToString()
@@ -51,12 +51,18 @@ namespace System.Windows.Forms {
                        return str;
                }
 
-               [MonoTODO]
                protected override void CreateHandle()
                {
+                       initCommonControlsLibrary ( );
                        base.CreateHandle();
                }
 
+               [MonoTODO]
+               protected override void Dispose(bool disposing) {
+                       // FIXME:
+                       base.Dispose(disposing);
+               }
+
                protected virtual void OnDrawItem(StatusBarDrawItemEventArgs e)
                {
                        if( DrawItem != null)
@@ -79,8 +85,9 @@ namespace System.Windows.Forms {
                [MonoTODO]
                protected override void OnLayout(LayoutEventArgs e)
                {
-                       //FIXME:
                        base.OnLayout(e);
+                       if ( IsHandleCreated )
+                               UpdateParts ( );
                }
 
                [MonoTODO]
@@ -231,24 +238,17 @@ namespace System.Windows.Forms {
                [MonoTODO]
                protected override CreateParams CreateParams {
                        get {
-                               CreateParams createParams = new CreateParams ();
+                               CreateParams createParams = base.CreateParams;
 
-                               createParams.Caption = Text;
                                createParams.ClassName = "msctls_statusbar32";
-                               createParams.X = Left;
-                               createParams.Y = Top;
-                               createParams.Width = Width;
-                               createParams.Height = Height;
-                               createParams.ClassStyle = 0;
-                               createParams.ExStyle = 0;
-                               createParams.Param = 0;
-                               createParams.Parent = Parent.Handle;
+
                                createParams.Style = (int) (
                                        WindowStyles.WS_CHILD | 
                                        WindowStyles.WS_VISIBLE |
                                        WindowStyles.WS_OVERLAPPED |
                                        WindowStyles.WS_CLIPCHILDREN |
-                                       WindowStyles.WS_CLIPCHILDREN );
+                                       WindowStyles.WS_CLIPCHILDREN ) |
+                                       (int)( CommonControlStyles.CCS_NORESIZE );
 
                                if( SizingGrip )
                                        createParams.Style |= (int)StatusbarControlStyles.SBARS_SIZEGRIP;
@@ -274,11 +274,11 @@ namespace System.Windows.Forms {
                                CalculatePanelWidths ( array );
                                int size = array.Length;
 
-                               IntPtr buffer = Marshal.AllocCoTaskMem( Marshal.SizeOf( size ) * size );
+                               IntPtr buffer = Marshal.AllocHGlobal ( Marshal.SizeOf( size ) * size );
                                Marshal.Copy( array, 0, buffer, size );
                                Win32.SendMessage( Handle, (int)StatusbarMessages.SB_SETPARTS, size, buffer.ToInt32() );
                                Win32.SendMessage( Handle, (int)StatusbarMessages.SB_SIMPLE, 0, 0 );
-                               Marshal.FreeCoTaskMem( buffer );
+                               Marshal.FreeHGlobal ( buffer );
                        }
                        else {
                                Win32.SendMessage( Handle, (int)StatusbarMessages.SB_SIMPLE, 1, 0 );
@@ -407,6 +407,14 @@ namespace System.Windows.Forms {
                        }
                }
 
+               private void initCommonControlsLibrary ( ) {
+                       if ( !RecreatingHandle ) {
+                               INITCOMMONCONTROLSEX    initEx = new INITCOMMONCONTROLSEX();
+                               initEx.dwICC = CommonControlInitFlags.ICC_BAR_CLASSES;
+                               Win32.InitCommonControlsEx(initEx);
+                       }
+               }
+
                //
                // System.Windows.Forms.StatusBar.StatusBarPanelCollection
                //