using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { bool shaded = false; Size oldSize = Size.Empty; public Form1() { InitializeComponent(); } protected override void WndProc(ref Message m) { if (m.Msg == NativeMethods.WM_SYSCOMMAND) { if (NativeMethods.Util.LOWORD(m.WParam) == NativeMethods.SC_MINIMIZE) { if (shaded) { this.Size = oldSize; this.shaded = false; } else { this.oldSize = this.Size; this.Size = new Size(this.Width, 0); this.shaded = true; } return; } } base.WndProc(ref m); } } static class NativeMethods { public const int WM_SYSCOMMAND = 0x112; public const int SC_MINIMIZE = 0xf020; public static class Util { public static int LOWORD(IntPtr p) { return LOWORD(unchecked((int)(long)p)); } public static int LOWORD(int i) { return i & 0xFFFF; } } } }