Transparent form window


   

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

  public class MainForm : System.Windows.Forms.Form
  {
    private System.ComponentModel.Container components;

    public MainForm()
    {
      InitializeComponent();
      BackColor = Color.Tomato;
      Opacity = 0.5d;
      Text = "www.kutayzorlu.com/java2s/com";
      Cursor = Cursors.WaitCursor;
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
    }

    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if (components != null) 
        {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }

    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Text = "Form1";
    }
    [STAThread]
    static void Main() 
    {
      Application.Run(new MainForm());
    }

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      g.DrawString("www.kutayzorlu.com/java2s/com", 
        new Font("Times New Roman", 20), 
        new SolidBrush(Color.Black), 40, 10);
    }
  }



           
          


Transparent window: set Opacity

   

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

public class Form1 : Form
{
  private System.Windows.Forms.GroupBox GroupBox1;
  private System.Windows.Forms.Button cmdApply;
  private System.Windows.Forms.NumericUpDown udOpacity;
  private System.Windows.Forms.Label Label1;

  public Form1() {
        InitializeComponent();
  }


  private void cmdApply_Click(object sender, EventArgs e)
  {
    this.Opacity = (double)udOpacity.Value / 100;
  }
  private void InitializeComponent()
  {
    this.GroupBox1 = new System.Windows.Forms.GroupBox();
    this.cmdApply = new System.Windows.Forms.Button();
    this.udOpacity = new System.Windows.Forms.NumericUpDown();
    this.Label1 = new System.Windows.Forms.Label();
    this.GroupBox1.SuspendLayout();
    ((System.ComponentModel.ISupportInitialize)(this.udOpacity)).BeginInit();
    this.SuspendLayout();
    // 
    // GroupBox1
    // 
    this.GroupBox1.Controls.Add(this.cmdApply);
    this.GroupBox1.Controls.Add(this.udOpacity);
    this.GroupBox1.Controls.Add(this.Label1);
    this.GroupBox1.Location = new System.Drawing.Point(12, 89);
    this.GroupBox1.Name = "GroupBox1";
    this.GroupBox1.Size = new System.Drawing.Size(268, 116);
    this.GroupBox1.TabIndex = 5;
    this.GroupBox1.TabStop = false;
    // 
    // cmdApply
    // 
    this.cmdApply.Location = new System.Drawing.Point(172, 64);
    this.cmdApply.Name = "cmdApply";
    this.cmdApply.Size = new System.Drawing.Size(80, 24);
    this.cmdApply.TabIndex = 5;
    this.cmdApply.Text = "Apply";
    this.cmdApply.Click += new System.EventHandler(this.cmdApply_Click);
    // 
    // udOpacity
    // 
    this.udOpacity.Increment = new decimal(new int[] {
        5,
        0,
        0,
        0});
    this.udOpacity.Location = new System.Drawing.Point(88, 32);
    this.udOpacity.Name = "udOpacity";
    this.udOpacity.Size = new System.Drawing.Size(48, 21);
    this.udOpacity.TabIndex = 4;
    this.udOpacity.Value = new decimal(new int[] {
        50,
        0,
        0,
        0});
    // 
    // Label1
    // 
    this.Label1.Location = new System.Drawing.Point(20, 36);
    this.Label1.Name = "Label1";
    this.Label1.Size = new System.Drawing.Size(56, 16);
    this.Label1.TabIndex = 3;
    this.Label1.Text = "Opacity:";
    // 
    // Transparent
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(309, 289);
    this.Controls.Add(this.GroupBox1);
    this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Name = "Transparent";
    this.Text = "Transparent";
    this.GroupBox1.ResumeLayout(false);
    ((System.ComponentModel.ISupportInitialize)(this.udOpacity)).EndInit();
    this.ResumeLayout(false);

  }


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

}



           
          


Transparent window: holes

   


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

public class Form1 : Form
{
  private System.Windows.Forms.PictureBox PictureBox4;
  private System.Windows.Forms.PictureBox PictureBox2;
  private System.Windows.Forms.PictureBox PictureBox1;
  private System.Windows.Forms.PictureBox PictureBox3;

  public Form1() {
        InitializeComponent();
  }

  private void InitializeComponent()
  {
    this.PictureBox4 = new System.Windows.Forms.PictureBox();
    this.PictureBox2 = new System.Windows.Forms.PictureBox();
    this.PictureBox1 = new System.Windows.Forms.PictureBox();
    this.PictureBox3 = new System.Windows.Forms.PictureBox();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox4)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox2)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox3)).BeginInit();
    this.SuspendLayout();
    // 
    // PictureBox4
    // 
    this.PictureBox4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
    this.PictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    this.PictureBox4.Location = new System.Drawing.Point(156, 141);
    this.PictureBox4.Name = "PictureBox4";
    this.PictureBox4.Size = new System.Drawing.Size(76, 76);
    this.PictureBox4.TabIndex = 14;
    this.PictureBox4.TabStop = false;
    // 
    // PictureBox2
    // 
    this.PictureBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
    this.PictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    this.PictureBox2.Location = new System.Drawing.Point(60, 141);
    this.PictureBox2.Name = "PictureBox2";
    this.PictureBox2.Size = new System.Drawing.Size(76, 76);
    this.PictureBox2.TabIndex = 13;
    this.PictureBox2.TabStop = false;
    // 
    // PictureBox1
    // 
    this.PictureBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
    this.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    this.PictureBox1.Location = new System.Drawing.Point(156, 49);
    this.PictureBox1.Name = "PictureBox1";
    this.PictureBox1.Size = new System.Drawing.Size(76, 76);
    this.PictureBox1.TabIndex = 12;
    this.PictureBox1.TabStop = false;
    // 
    // PictureBox3
    // 
    this.PictureBox3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
    this.PictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    this.PictureBox3.Location = new System.Drawing.Point(60, 49);
    this.PictureBox3.Name = "PictureBox3";
    this.PictureBox3.Size = new System.Drawing.Size(76, 76);
    this.PictureBox3.TabIndex = 11;
    this.PictureBox3.TabStop = false;
    // 
    // Holes
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.PictureBox4);
    this.Controls.Add(this.PictureBox2);
    this.Controls.Add(this.PictureBox1);
    this.Controls.Add(this.PictureBox3);
    this.Name = "Holes";
    this.Text = "Holes";
    this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox4)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox2)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.PictureBox3)).EndInit();
    this.ResumeLayout(false);

  }

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

}


           
          


Image List Example


/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.IO;

namespace ImageListExample
{
///

/// Summary description for ImageListExample.
///

public class ImageListExample : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button cmdDrawImageList;
internal System.Windows.Forms.Button cmdFillImageList;
///

/// Required designer variable.
///

private System.ComponentModel.Container components = null;

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

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///

/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///

/// Required method for Designer support – do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.cmdDrawImageList = new System.Windows.Forms.Button();
this.cmdFillImageList = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmdDrawImageList
//
this.cmdDrawImageList.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdDrawImageList.Location = new System.Drawing.Point(164, 172);
this.cmdDrawImageList.Name = “cmdDrawImageList”;
this.cmdDrawImageList.Size = new System.Drawing.Size(96, 24);
this.cmdDrawImageList.TabIndex = 3;
this.cmdDrawImageList.Text = “Draw Images”;
this.cmdDrawImageList.Click += new System.EventHandler(this.cmdDrawImageList_Click);
//
// cmdFillImageList
//
this.cmdFillImageList.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdFillImageList.Location = new System.Drawing.Point(28, 172);
this.cmdFillImageList.Name = “cmdFillImageList”;
this.cmdFillImageList.Size = new System.Drawing.Size(104, 24);
this.cmdFillImageList.TabIndex = 2;
this.cmdFillImageList.Text = “Fill ImageList”;
this.cmdFillImageList.Click += new System.EventHandler(this.cmdFillImageList_Click);
//
// ImageListExample
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 214);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.cmdDrawImageList,
this.cmdFillImageList});
this.Name = “ImageListExample”;
this.Text = “ImageList Example”;
this.ResumeLayout(false);

}
#endregion

///

/// The main entry point for the application.
///

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

ImageList iconImages = new System.Windows.Forms.ImageList();

private void cmdFillImageList_Click(object sender, System.EventArgs e)
{
// Configure the ImageList.
iconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
iconImages.ImageSize = new System.Drawing.Size(16, 16);

// Get all the icon files in the current directory.
string[] iconFiles = Directory.GetFiles(Application.StartupPath, “*.ico”);

// Create an Image object for each file and add it to the ImageList.
// You can also use an Image subclass (like Icon).
foreach (string iconFile in iconFiles)
{
Icon newIcon = new Icon(iconFile);
iconImages.Images.Add(newIcon);
}
}

private void cmdDrawImageList_Click(object sender, System.EventArgs e)
{
// Get the graphics device context for the form.
Graphics g = this.CreateGraphics();

// Draw each image using the ImageList.Draw() method.
for (int i = 0; i < iconImages.Images.Count; i++) { iconImages.Draw(g, 30 + i * 30, 30, i); } // Release the graphics device context. g.Dispose(); } } } ImageListExample.zip( 24 k)[/csharp]

Add to and get Image from Image List

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

public class Form1 : Form
{
private System.Windows.Forms.Button cmdFillImageList;
private System.Windows.Forms.Button cmdPaintImages;
private System.Windows.Forms.ImageList iconImages;

public Form1() {
InitializeComponent();
}

private void cmdFillImageList_Click(object sender, EventArgs e)
{
iconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
iconImages.ImageSize = new System.Drawing.Size(16, 16);

string[] iconFiles = Directory.GetFiles(Application.StartupPath, “*.ico”);

foreach (string iconFile in iconFiles)
{
Icon newIcon = new Icon(iconFile);
iconImages.Images.Add(newIcon);
}
}

private void cmdPaintImages_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();

for (int i = 0; i < iconImages.Images.Count; i++) { iconImages.Draw(g, 30 + i * 30, 30, i); } g.Dispose(); } private void InitializeComponent() { this.cmdFillImageList = new System.Windows.Forms.Button(); this.cmdPaintImages = new System.Windows.Forms.Button(); this.iconImages = new System.Windows.Forms.ImageList(new System.ComponentModel.Container()); this.SuspendLayout(); // // cmdFillImageList // this.cmdFillImageList.Location = new System.Drawing.Point(29, 217); this.cmdFillImageList.Name = "cmdFillImageList"; this.cmdFillImageList.Size = new System.Drawing.Size(118, 23); this.cmdFillImageList.TabIndex = 0; this.cmdFillImageList.Text = "Fill Image List"; this.cmdFillImageList.UseVisualStyleBackColor = true; this.cmdFillImageList.Click += new System.EventHandler(this.cmdFillImageList_Click); // // cmdPaintImages // this.cmdPaintImages.Location = new System.Drawing.Point(153, 217); this.cmdPaintImages.Name = "cmdPaintImages"; this.cmdPaintImages.Size = new System.Drawing.Size(112, 23); this.cmdPaintImages.TabIndex = 1; this.cmdPaintImages.Text = "Paint Images"; this.cmdPaintImages.UseVisualStyleBackColor = true; this.cmdPaintImages.Click += new System.EventHandler(this.cmdPaintImages_Click); // // iconImages // this.iconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; this.iconImages.ImageSize = new System.Drawing.Size(16, 16); this.iconImages.TransparentColor = System.Drawing.Color.Transparent; // // ImageListTest // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.cmdPaintImages); this.Controls.Add(this.cmdFillImageList); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Name = "ImageListTest"; this.Text = "ImageListTest"; this.ResumeLayout(false); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } } [/csharp]

Help icon



   

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/

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

namespace ExtenderProviderHost
{
  /// <summary>
  /// Summary description for HelpIconProviderHost.
  /// </summary>
  public class HelpIconProviderHost : System.Windows.Forms.Form
  {
    internal System.Windows.Forms.TextBox TextBox2;
    internal System.Windows.Forms.TextBox TextBox1;
    private ExtenderProviderControls.HelpIconProvider helpIconProvider1;
    private System.ComponentModel.IContainer components;

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

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <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.TextBox2 = new System.Windows.Forms.TextBox();
      this.TextBox1 = new System.Windows.Forms.TextBox();
      this.helpIconProvider1 = new ExtenderProviderControls.HelpIconProvider(this.components);
      this.SuspendLayout();
      // 
      // TextBox2
      // 
      this.TextBox2.Location = new System.Drawing.Point(24, 48);
      this.TextBox2.Name = "TextBox2";
      this.TextBox2.Size = new System.Drawing.Size(148, 20);
      this.TextBox2.TabIndex = 3;
      this.TextBox2.Text = "";
      // 
      // TextBox1
      // 
      this.TextBox1.Location = new System.Drawing.Point(24, 16);
      this.TextBox1.Name = "TextBox1";
      this.TextBox1.Size = new System.Drawing.Size(104, 20);
      this.TextBox1.TabIndex = 2;
      this.TextBox1.Text = "";
      // 
      // helpIconProvider1
      // 
      this.helpIconProvider1.HelpFile = null;
      // 
      // HelpIconProviderHost
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 150);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.TextBox2,
                                      this.TextBox1});
      this.Name = "HelpIconProviderHost";
      this.Text = "HelpIconProviderHost";
      this.Load += new System.EventHandler(this.HelpIconProviderHost_Load);
      this.ResumeLayout(false);

    }
    #endregion

    private void HelpIconProviderHost_Load(object sender, System.EventArgs e)
    {
      helpIconProvider1.HelpFile = "myhelp.hlp";
      helpIconProvider1.SetHelpID(TextBox1, "10001");
      helpIconProvider1.SetHelpID(TextBox2, "10002");
      helpIconProvider1.SetHelpID(TextBox1,"");
    }

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


//=============================================================
//=============================================================

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

namespace ExtenderProviderControls
{
[ProvideProperty("HelpID", typeof(string))]
public class HelpIconProvider : Component, IExtenderProvider
{

  private System.ComponentModel.Container components = null;

  public HelpIconProvider(System.ComponentModel.IContainer container)
  {
    /// <summary>
    /// Required for Windows.Forms Class Composition Designer support
    /// </summary>
    container.Add(this);
    InitializeComponent();

    //
    // TODO: Add any constructor code after InitializeComponent call
    //
  }

  public HelpIconProvider()
  {
    /// <summary>
    /// Required for Windows.Forms Class Composition Designer support
    /// </summary>
    InitializeComponent();

    //
    // TODO: Add any constructor code after InitializeComponent call
    //
  }

    #region Component 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()
  {
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(HelpIconProvider));
    this.pictureBox1 = new System.Windows.Forms.PictureBox();
    // 
    // pictureBox1
    // 
    this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
    this.pictureBox1.Location = new System.Drawing.Point(17, 17);
    this.pictureBox1.Name = "pictureBox1";
    this.pictureBox1.TabIndex = 0;
    this.pictureBox1.TabStop = false;

  }
    #endregion


    private Hashtable contextID = new Hashtable();
  private Hashtable pictures = new Hashtable();
  private System.Windows.Forms.PictureBox pictureBox1;
    private string helpFile;

    public bool CanExtend(object extendee)
    {
        if (extendee.GetType() == typeof(Control))
        {
            // Ensure the control is attached to a form.
            if (((Control)extendee).FindForm() == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        else
        {
            return false;
        }
    }

    public string HelpFile
  {
    get
        {
            return helpFile;
        }
        set
        {
            helpFile = value;
        }
    }

    public void SetHelpID(object extendee, string value)
    {
        Control ctrl = (Control)extendee;

        // Specifying an empty value removes the extension.
        if (value == "")
        {
            contextID.Remove(extendee);

      // Remove the picture.
      PictureBox pic = (PictureBox)pictures[extendee];
      pic.DoubleClick -= new EventHandler(PicDoubleClick);

      pic.Parent.Controls.Remove(pic);
      pictures.Remove(extendee);
        }
        else
        {
            contextID[extendee] = value;

            // Create new icon.
            PictureBox pic = new PictureBox();
            pic.Image = pictureBox1.Image;
            
            // Store a reference to the related control in the PictureBox.
            pic.Tag = extendee;

            pic.Size = new Size(16, 16);
            pic.Location = new Point(ctrl.Right + 10, ctrl.Top);
            ctrl.Parent.Controls.Add(pic);

            // Register for DoubleClick event.
            pic.DoubleClick += new EventHandler(PicDoubleClick);

      // Store a reference to the help icon so we can remove it later.
      pictures[extendee] = pic;
        }
    }

    public string GetHelpID(object extendee)
    {
        if (contextID[extendee] != null)
        {
            return contextID[extendee].ToString();
        }
        else
        {
            return String.Empty;
        }
    }

    public void PicDoubleClick(object sender, EventArgs e)
    {
        // Invoke help for control.
        Control ctrlRelated = (Control)((Control)sender).Tag;

    // Debug message.
    MessageBox.Show("Help triggered.");

        Help.ShowHelp(ctrlRelated, helpFile, HelpNavigator.Topic, 
          contextID[ctrlRelated].ToString());
    }

}

}


           
          


HelpIconProviderHost.zip( 72 k)

Help Test



   

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/


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

namespace HelpTest
{
  /// <summary>
  /// Summary description for HelpTest.
  /// </summary>
  public class HelpTest : System.Windows.Forms.Form
  {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

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

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <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()
    {
      // 
      // HelpTest
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(528, 434);
      this.IsMdiContainer = true;
      this.Name = "HelpTest";
      this.Text = "HelpTest";
      this.Load += new System.EventHandler(this.HelpTest_Load);

    }
    #endregion

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

    private void HelpTest_Load(object sender, System.EventArgs e)
    {
      FormBased frm1 = new FormBased();
      FrameBased frm2 = new FrameBased();
      ControlBased frm3 = new ControlBased();
      
      frm1.MdiParent = this;
      frm2.MdiParent = this;
      frm3.MdiParent = this;
      
      frm1.Show();
      frm2.Show();
      frm3.Show();
    }
  }
}


//===============================================================
//===============================================================

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

namespace HelpTest
{
  /// <summary>
  /// Summary description for ControlBased.
  /// </summary>
  public class ControlBased : System.Windows.Forms.Form
  {
    internal System.Windows.Forms.TextBox TextBox1;
    internal System.Windows.Forms.ListBox ListBox1;
    internal System.Windows.Forms.Label label1;
    internal System.Windows.Forms.HelpProvider HelpProvider1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

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

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <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.TextBox1 = new System.Windows.Forms.TextBox();
      this.ListBox1 = new System.Windows.Forms.ListBox();
      this.label1 = new System.Windows.Forms.Label();
      this.HelpProvider1 = new System.Windows.Forms.HelpProvider();
      this.SuspendLayout();
      // 
      // TextBox1
      // 
      this.TextBox1.Location = new System.Drawing.Point(30, 135);
      this.TextBox1.Name = "TextBox1";
      this.TextBox1.Size = new System.Drawing.Size(208, 20);
      this.TextBox1.TabIndex = 11;
      this.TextBox1.Text = "TextBox1";
      // 
      // ListBox1
      // 
      this.ListBox1.Location = new System.Drawing.Point(26, 19);
      this.ListBox1.Name = "ListBox1";
      this.ListBox1.Size = new System.Drawing.Size(112, 95);
      this.ListBox1.TabIndex = 10;
      // 
      // label1
      // 
      this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.label1.Location = new System.Drawing.Point(30, 179);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(236, 68);
      this.label1.TabIndex = 9;
      this.label1.Text = "Select a control and press F1 here for a control-based help topic.";
      // 
      // ControlBased
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 266);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.TextBox1,
                                      this.ListBox1,
                                      this.label1});
      this.Name = "ControlBased";
      this.Text = "ControlBased";
      this.Load += new System.EventHandler(this.ControlBased_Load);
      this.ResumeLayout(false);

    }
    #endregion

    private void ControlBased_Load(object sender, System.EventArgs e)
    {
      HelpProvider1.HelpNamespace = "sample.chm";
      HelpProvider1.SetHelpKeyword(TextBox1, "1007.html");
      HelpProvider1.SetHelpNavigator(TextBox1, HelpNavigator.Topic);
      HelpProvider1.SetHelpKeyword(ListBox1, "1006.html");
      HelpProvider1.SetHelpNavigator(ListBox1, HelpNavigator.Topic);
    }
  }
}



           
          


HelpTest.zip( 58 k)