CheckBox inside GroupBox


   

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Group
{
  /// <summary>
  /// Summary description for FormGroup.
  /// </summary>
  public class FormGroup : System.Windows.Forms.Form
  {
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.CheckBox checkBox1;
    private System.Windows.Forms.CheckBox checkBox2;
    private System.Windows.Forms.CheckBox checkBox3;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public FormGroup()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      Application.Idle += new System.EventHandler (OnIdle);

    }

    private void OnIdle (object sender, EventArgs e)
    {
      groupBox1.Enabled = checkBox3.Checked;
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.checkBox3 = new System.Windows.Forms.CheckBox();
      this.checkBox2 = new System.Windows.Forms.CheckBox();
      this.textBox1 = new System.Windows.Forms.TextBox();
      this.groupBox1 = new System.Windows.Forms.GroupBox();
      this.checkBox1 = new System.Windows.Forms.CheckBox();
      this.groupBox1.SuspendLayout();
      this.SuspendLayout();
      // 
      // checkBox3
      // 
      this.checkBox3.Location = new System.Drawing.Point(24, 120);
      this.checkBox3.Name = "checkBox3";
      this.checkBox3.Size = new System.Drawing.Size(184, 16);
      this.checkBox3.TabIndex = 1;
      this.checkBox3.Text = "checkBox3";
      // 
      // checkBox2
      // 
      this.checkBox2.Location = new System.Drawing.Point(136, 56);
      this.checkBox2.Name = "checkBox2";
      this.checkBox2.Size = new System.Drawing.Size(104, 16);
      this.checkBox2.TabIndex = 2;
      this.checkBox2.Text = "checkBox2";
      // 
      // textBox1
      // 
      this.textBox1.Location = new System.Drawing.Point(16, 24);
      this.textBox1.Name = "textBox1";
      this.textBox1.Size = new System.Drawing.Size(232, 20);
      this.textBox1.TabIndex = 0;
      this.textBox1.Text = "textBox1";
      // 
      // groupBox1
      // 
      this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                          this.checkBox2,
                                          this.checkBox1,
                                          this.textBox1});
      this.groupBox1.Location = new System.Drawing.Point(16, 16);
      this.groupBox1.Name = "groupBox1";
      this.groupBox1.Size = new System.Drawing.Size(264, 96);
      this.groupBox1.TabIndex = 0;
      this.groupBox1.TabStop = false;
      this.groupBox1.Text = "groupBox1";
      // 
      // checkBox1
      // 
      this.checkBox1.Location = new System.Drawing.Point(16, 56);
      this.checkBox1.Name = "checkBox1";
      this.checkBox1.Size = new System.Drawing.Size(104, 16);
      this.checkBox1.TabIndex = 1;
      this.checkBox1.Text = "checkBox1";
      // 
      // FormGroup
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.checkBox3,
                                      this.groupBox1});
      this.Name = "FormGroup";
      this.Text = "FormGroup";
      this.groupBox1.ResumeLayout(false);
      this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
      Application.Run(new FormGroup());
    }
  }
}



           
          


Using GroupBoxes and Panels to hold buttons


   

   using System;
   using System.Drawing;
   using System.Collections;
   using System.ComponentModel;
   using System.Windows.Forms;
   using System.Data;

   public class GroupBoxPanelExample : System.Windows.Forms.Form
   {
      private System.Windows.Forms.Button hiButton;
      private System.Windows.Forms.Button byeButton;
      private System.Windows.Forms.Button leftButton;
      private System.Windows.Forms.Button rightButton;

      private System.Windows.Forms.GroupBox mainGroupBox;
      private System.Windows.Forms.Label messageLabel;
      private System.Windows.Forms.Panel mainPanel;

      public GroupBoxPanelExample()
      {
         InitializeComponent();
      }
      private void InitializeComponent()
      {
         this.messageLabel = new System.Windows.Forms.Label();
         this.byeButton = new System.Windows.Forms.Button();
         this.mainGroupBox = new System.Windows.Forms.GroupBox();
         this.hiButton = new System.Windows.Forms.Button();
         this.mainPanel = new System.Windows.Forms.Panel();
         this.rightButton = new System.Windows.Forms.Button();
         this.leftButton = new System.Windows.Forms.Button();
         this.mainGroupBox.SuspendLayout();
         this.mainPanel.SuspendLayout();
         this.SuspendLayout();

         this.messageLabel.Location = new System.Drawing.Point( 24, 144 );
         this.messageLabel.Name = "messageLabel";
         this.messageLabel.Size = new System.Drawing.Size( 176, 32 );
         this.messageLabel.TabIndex = 2;

         this.byeButton.Location = new System.Drawing.Point( 96, 48 );
         this.byeButton.Name = "byeButton";
         this.byeButton.Size = new System.Drawing.Size( 72, 32 );
         this.byeButton.TabIndex = 0;
         this.byeButton.Text = "B";

         this.byeButton.Click += new System.EventHandler( this.byeButton_Click );

         this.mainGroupBox.Controls.AddRange( new System.Windows.Forms.Control[] {
            this.byeButton, this.hiButton } );
         this.mainGroupBox.Location = new System.Drawing.Point( 24, 24 );
         this.mainGroupBox.Name = "mainGroupBox";
         this.mainGroupBox.Size = new System.Drawing.Size( 176, 104 );
         this.mainGroupBox.TabIndex = 0;
         this.mainGroupBox.TabStop = false;
         this.mainGroupBox.Text = "Main GroupBox";

         this.hiButton.Location = new System.Drawing.Point( 8, 48 );
         this.hiButton.Name = "hiButton";
         this.hiButton.Size = new System.Drawing.Size( 72, 32 );
         this.hiButton.TabIndex = 0;
         this.hiButton.Text = "A";
         this.hiButton.Click += new System.EventHandler(this.hiButton_Click );

         this.mainPanel.AutoScroll = true;
         this.mainPanel.BorderStyle =System.Windows.Forms.BorderStyle.FixedSingle;

         this.mainPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
            this.rightButton,this.leftButton } );
         this.mainPanel.Location =new System.Drawing.Point( 24, 192 );
         this.mainPanel.Name = "mainPanel";
         this.mainPanel.Size =new System.Drawing.Size( 176, 112 );
         this.mainPanel.TabIndex = 1;

         this.rightButton.Location =new System.Drawing.Point( 264, 40 );
         this.rightButton.Name = "rightButton";
         this.rightButton.Size =new System.Drawing.Size( 80, 40 );
         this.rightButton.TabIndex = 0;
         this.rightButton.Text = "Far Right";
         this.rightButton.Click += new System.EventHandler(this.rightButton_Click );

         this.leftButton.Location =new System.Drawing.Point( 8, 40 );
         this.leftButton.Name = "leftButton";
         this.leftButton.Size =new System.Drawing.Size( 80, 40 );
         this.leftButton.TabIndex = 0;
         this.leftButton.Text = "Far Left";
         this.leftButton.Click +=new System.EventHandler( this.leftButton_Click );

         this.AutoScaleBaseSize =new System.Drawing.Size( 5, 13 );
         this.ClientSize =new System.Drawing.Size( 224, 317 );
         this.Controls.AddRange(new System.Windows.Forms.Control[] {
               this.messageLabel,this.mainPanel,this.mainGroupBox } );
         this.Name = "GroupBoxPanelExample";
         this.Text = "GroupBoxPanelExample";
         this.mainGroupBox.ResumeLayout( false );
         this.mainPanel.ResumeLayout( false );
         this.ResumeLayout( false );

      }
      [STAThread]
      static void Main() 
      {
         Application.Run( new GroupBoxPanelExample() );
      }

      private void hiButton_Click( object sender, System.EventArgs e )
      {
         messageLabel.Text= "A pressed";
      }

      private void byeButton_Click(object sender, System.EventArgs e )
      {
         messageLabel.Text = "B pressed";
      }

      private void leftButton_Click(object sender, System.EventArgs e )
      {
         messageLabel.Text = "Far left pressed";
      }

      private void rightButton_Click( 
         object sender, System.EventArgs e )
      {
         messageLabel.Text = "Far right pressed";
      }
   }



           
          


Group Box mouse enter event


   


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form {
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.CheckBox checkBox1;
    private System.Windows.Forms.CheckBox checkBox2;
    private System.Windows.Forms.CheckBox checkBox3;
    private System.Windows.Forms.RadioButton radioButton1;
    private System.Windows.Forms.RadioButton radioButton2;
    private System.Windows.Forms.RadioButton radioButton3;
    private System.Windows.Forms.Button button1;

    private System.ComponentModel.Container components = null;

    public Form1() {
      InitializeComponent();
    }

    private void InitializeComponent() {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.checkBox1 = new System.Windows.Forms.CheckBox();
            this.checkBox2 = new System.Windows.Forms.CheckBox();
            this.checkBox3 = new System.Windows.Forms.CheckBox();
            this.radioButton1 = new System.Windows.Forms.RadioButton();
            this.radioButton2 = new System.Windows.Forms.RadioButton();
            this.radioButton3 = new System.Windows.Forms.RadioButton();
            this.button1 = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                    this.radioButton1,
                                                                                    this.radioButton2,
                                                                                    this.radioButton3});
            this.groupBox1.Location = new System.Drawing.Point(8, 120);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(120, 144);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Color";
            this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
            // 
            // checkBox1
            // 
            this.checkBox1.Location = new System.Drawing.Point(8, 8);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.TabIndex = 1;
            this.checkBox1.Text = "Circle";
            // 
            // checkBox2
            // 
            this.checkBox2.Location = new System.Drawing.Point(8, 40);
            this.checkBox2.Name = "checkBox2";
            this.checkBox2.TabIndex = 2;
            this.checkBox2.Text = "Rectangle";
            // 
            // checkBox3
            // 
            this.checkBox3.Location = new System.Drawing.Point(8, 72);
            this.checkBox3.Name = "checkBox3";
            this.checkBox3.TabIndex = 3;
            this.checkBox3.Text = "String";
            // 
            // radioButton1
            // 
            this.radioButton1.Location = new System.Drawing.Point(8, 32);
            this.radioButton1.Name = "radioButton1";
            this.radioButton1.TabIndex = 4;
            this.radioButton1.Text = "Red";
            this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
            // 
            // radioButton2
            // 
            this.radioButton2.Location = new System.Drawing.Point(8, 64);
            this.radioButton2.Name = "radioButton2";
            this.radioButton2.TabIndex = 5;
            this.radioButton2.Text = "Green";
            // 
            // radioButton3
            // 
            this.radioButton3.Location = new System.Drawing.Point(8, 96);
            this.radioButton3.Name = "radioButton3";
            this.radioButton3.TabIndex = 6;
            this.radioButton3.Text = "Blue";
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(8, 280);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(112, 32);
            this.button1.TabIndex = 4;
            this.button1.Text = "Draw";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(408, 317);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.button1,
                                                                          this.checkBox3,
                                                                          this.checkBox2,
                                                                          this.checkBox1,
                                                                          this.groupBox1});
            this.Name = "Form1";
            this.Text = "CheckBox and RadioButton Sample";
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        private void groupBox1_Enter(object sender, System.EventArgs e)
        {
           Console.WriteLine("group box enter event");
        }

        private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
        {
           Console.WriteLine("Radio Button checked changed event");
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            Graphics g = Graphics.FromHwnd(this.Handle);
            String str = "";
            Rectangle rc = new Rectangle(150, 50, 250, 250);
            
            if(radioButton1.Checked)
            {
                str = "red";
            }
            if(radioButton2.Checked)
            {
                str+="Green";
            }
            if(radioButton3.Checked)
            {
                str+="Blue";
            }

            if (checkBox1.Checked)
            {
                str+="Ellipse";
            }
            if (checkBox2.Checked)
            {
                str += "Rectangle";
            }
            if (checkBox3.Checked)
            {
                g.FillRectangle(new SolidBrush(Color.White), rc);
                g.DrawString(str, new Font("Verdana", 12), new SolidBrush(Color.Black), rc);
            }
            

        }
    }


           
          


Full screen and KeyEvent and MouseEvent

   

// This Article is a simple one to show the usage of KeyEvent and MouseEvent. 
  
// Please move the mouse or press a key to Exit this Program. 
using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using System.Data; 

namespace ScreenSave 
{ 
    public class KeyEventandMouseEvent : System.Windows.Forms.Form { 
        private System.Windows.Forms.Label label1; 
        private System.Windows.Forms.Timer timer1; 
        private System.ComponentModel.IContainer components; 
        private Boolean boolFlag; 
        private int ixStart; 
        private int iyStart; 
    
        public KeyEventandMouseEvent() { 
            // 
            // Required for Windows Form Designer support 
            // 
            InitializeComponent(); 
        } 
        /// <summary> 
        /// Clean up any resources being used. 
        /// </summary> 
        protected override void Dispose( bool disposing ) 
        { 
            if( disposing ) { 
                if (components != null) 
                { 
                    components.Dispose(); 
                } 
            } 
            base.Dispose( disposing ); 
        } 
        #region Windows Form Designer generated code 
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor. 
        /// </summary> 
        private void InitializeComponent() { 
            this.components = new System.ComponentModel.Container(); 
            this.timer1 = new System.Windows.Forms.Timer(this.components); 
            this.label1 = new System.Windows.Forms.Label(); 
            this.SuspendLayout(); 
            // 
            // timer1 
            // 
            this.timer1.Enabled = true; 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 
            // 
            // label1 
            // 
            this.label1.Font = new System.Drawing.Font("Times New Roman", 14F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); 
            this.label1.ForeColor = System.Drawing.Color.Lime; 
            this.label1.Location = new System.Drawing.Point(8, 280); 
            this.label1.Name = "label1"; 
            this.label1.Size = new System.Drawing.Size(312, 32); 
            this.label1.TabIndex = 0; 
            this.label1.Text = "Roller - Developed in C-Sharp"; 
            this.label1.Click += new System.EventHandler(this.label1_Click); 
            // 
            // KeyEventandMouseEvent 
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
            this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); 
            this.ClientSize = new System.Drawing.Size(568, 32); 
            this.Controls.AddRange(new System.Windows.Forms.Control[] { 
            this.label1}); 
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 
            this.KeyPreview = true; 
            this.Name = "KeyEventandMouseEvent"; 
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 
            this.Text = "KeyEventandMouseEvent"; 
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized; 
            this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnKeyPressEvent); 
            this.Load += new System.EventHandler(this.KeyEventandMouseEvent_Load); 
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMoveEvent); 
            this.ResumeLayout(false); 
        } 
        #endregion 
        /// <summary> 
        /// The main entry point for the application. 
        /// </summary> 
        [STAThread] 
        static void Main() 
        { 
            Application.Run(new KeyEventandMouseEvent()); 
        } 
        private void timer1_Tick(object sender, System.EventArgs e) 
        { 
            int i; 
              
            i = label1.Location.X; 
            if (i >= 750) 
            i = 0; 
            else 
            i = label1.Location.X + 5; 
              
            label1.Location = new Point(i,280); 
        } 
        private void KeyEventandMouseEvent_Load(object sender, System.EventArgs e) 
        { 
          
        } 
        private void OnMouseMoveEvent(object sender,MouseEventArgs e) 
        { 
            //Application.Exit(); 
            if (ixStart == 0 &amp;&amp; iyStart == 0) 
            { 
                ixStart = e.X; 
                iyStart = e.Y; 
            } 
            else if (e.X != ixStart || e.Y != iyStart) 
                Application.Exit(); 
              
        } 
        private void OnKeyPressEvent(object sender, System.Windows.Forms.KeyPressEventArgs e) 
        { 
            Application.Exit(); 
        } 
        private void label1_Click(object sender, System.EventArgs e) 
        { 
        } 
    } 
} 
 



           
          


MinimumWindow Size

   
 


using System;
using System.Drawing;
using System.Windows.Forms;
   
class HowdyWorldFullFit: Form
{
     public static void Main()
     {
          Application.Run(new HowdyWorldFullFit());
     }
     public HowdyWorldFullFit()
     {
          ResizeRedraw = true; 
          MinimumSize = SystemInformation.MinimumWindowSize + new Size(0,1);
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }     
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          Font  font  = new Font("Times New Roman", 10, FontStyle.Italic);
          SizeF sizef = grfx.MeasureString(Text, font);
          float fScaleHorz = cx / sizef.Width;
          float fScaleVert = cy / sizef.Height;
   
          grfx.ScaleTransform(fScaleHorz, fScaleVert);
   
          grfx.DrawString(Text, font, new SolidBrush(clr), 0, 0);
     }
}

    


Not in TaskBar


   


  using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class Form1 : System.Windows.Forms.Form
  {
    private Button myButton; 

    public Form1()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
        
            this.ShowInTaskbar=false;

      myButton = new Button();
      myButton.Text = "Minimize the window and you won&#039;t find it in TaskBar";
      myButton.Location = new System.Drawing.Point(64, 32);
      myButton.Size = new System.Drawing.Size(450, 50);
 
      Controls.Add(myButton);
    }

    static void Main() 
    {
      Application.Run(new Form1());
    }
  }

           
          


Self Placing Window (save form window related information to Registry)

   
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

    public class Form1 : Form
    {
        private System.Windows.Forms.ListBox listBoxMessages;
        private System.Windows.Forms.Button buttonChooseColor;
        private ColorDialog chooseColorDialog = new ColorDialog();

        public Form1()
        {
            this.listBoxMessages = new System.Windows.Forms.ListBox();
            this.buttonChooseColor = new System.Windows.Forms.Button();
            this.SuspendLayout();

            this.listBoxMessages.Size = new System.Drawing.Size(288, 199);

            this.buttonChooseColor.Location = new System.Drawing.Point(0, 208);
            this.buttonChooseColor.Size = new System.Drawing.Size(104, 23);
            this.buttonChooseColor.Text = "Choose Color";

            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(292, 232);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.buttonChooseColor,
                                      this.listBoxMessages});
            this.ResumeLayout(false);

            buttonChooseColor.Click += new EventHandler(OnClickChooseColor);

            try
            {
                if (ReadSettings() == false)
                    listBoxMessages.Items.Add("No information in registry");
                else
                    listBoxMessages.Items.Add("Information read in from registry");
                StartPosition = FormStartPosition.Manual;
            }
            catch (Exception e)
            {
                listBoxMessages.Items.Add("A problem occurred reading in data from registry:");
                listBoxMessages.Items.Add(e.Message);
            }
        }

        void OnClickChooseColor(object Sender, EventArgs e)
        {
            if (chooseColorDialog.ShowDialog() == DialogResult.OK)
                BackColor = chooseColorDialog.Color;
        }

        void SaveSettings()
        {
            RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
            RegistryKey wroxKey = softwareKey.CreateSubKey("JJJ");
            RegistryKey selfPlacingWindowKey = wroxKey.CreateSubKey("SelfPlacingWindow");
            selfPlacingWindowKey.SetValue("BackColor", (object)BackColor.ToKnownColor());
            selfPlacingWindowKey.SetValue("Red", (object)(int)BackColor.R);
            selfPlacingWindowKey.SetValue("Green", (object)(int)BackColor.G);
            selfPlacingWindowKey.SetValue("Blue", (object)(int)BackColor.B);
            selfPlacingWindowKey.SetValue("Width", (object)Width);
            selfPlacingWindowKey.SetValue("Height", (object)Height);
            selfPlacingWindowKey.SetValue("X", (object)DesktopLocation.X);
            selfPlacingWindowKey.SetValue("Y", (object)DesktopLocation.Y);
            selfPlacingWindowKey.SetValue("WindowState", (object)WindowState.ToString());
        }

        bool ReadSettings()
        {
            RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software");
            RegistryKey wroxKey = softwareKey.OpenSubKey("JJJ");
            if (wroxKey == null)
                return false;
            RegistryKey selfPlacingWindowKey =
                wroxKey.OpenSubKey("SelfPlacingWindow");
            if (selfPlacingWindowKey == null)
                return false;
            else
                listBoxMessages.Items.Add("Successfully opened key " + selfPlacingWindowKey.ToString());
            int redComponent = (int)selfPlacingWindowKey.GetValue("Red");
            int greenComponent = (int)selfPlacingWindowKey.GetValue("Green");
            int blueComponent = (int)selfPlacingWindowKey.GetValue("Blue");
            this.BackColor = Color.FromArgb(redComponent, greenComponent, blueComponent);
            listBoxMessages.Items.Add("Background color: " + BackColor.Name);
            int X = (int)selfPlacingWindowKey.GetValue("X");
            int Y = (int)selfPlacingWindowKey.GetValue("Y");
            this.DesktopLocation = new Point(X, Y);
            listBoxMessages.Items.Add("Desktop location: " + DesktopLocation.ToString());
            this.Height = (int)selfPlacingWindowKey.GetValue("Height");
            this.Width = (int)selfPlacingWindowKey.GetValue("Width");
            listBoxMessages.Items.Add("Size: " + new Size(Width, Height).ToString());
            string initialWindowState = (string)selfPlacingWindowKey.GetValue("WindowState");
            listBoxMessages.Items.Add("Window State: " + initialWindowState);
            this.WindowState = (FormWindowState)FormWindowState.Parse
                (WindowState.GetType(), initialWindowState);
            return true;
        }

        [STAThread]
        static void Main()
        {
            Application.Run(new Form1());
        }
    }