Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / C#

A Floating Popup Control

Rate me:
Please Sign up or sign in to vote.
3.64/5 (11 votes)
4 May 2006CPOL2 min read 115.8K   2.9K   68  
A floating popup control which can display any form.
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
namespace FloatingPopup
{
	/// <summary>
	/// Summary description for ComboButton.
	/// </summary>
	public class ComboButton : System.Windows.Forms.Button
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

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

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

		public ComboButton()
		{
			///
			/// Required for Windows.Forms Class Composition 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 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()
		{
			components = new System.ComponentModel.Container();
		}
		#endregion

		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);
			System.Drawing.SolidBrush br=new SolidBrush(Color.Black);
			Point []p=new Point[4];
			p[0].X=(this.Width-8)/2;
			p[0].Y=(this.Height-8)/2;
			p[1].X=p[0].X+8;
			p[1].Y=p[0].Y;
			p[2].X=p[0].X+4;
			p[2].Y=p[0].Y+6;
			p[3].X=p[0].X;
			p[3].Y=p[0].Y;
			e.Graphics.FillPolygon(br,p);
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions