⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 Wince没有提供不规则形状窗口的函数, 这个sample可以在在Wince上实现不规则窗口,全部源代码非常易于移植.
💻 CS
字号:
namespace ShapedWindow
{
	using System;
	using System.Reflection;
	using System.Drawing;
	using System.Collections;
	using System.Windows.Forms;
	using System.IO;
	using OpenNETCF;
	using OpenNETCF.Win32;
	using OpenNETCF.Drawing;
	using OpenNETCF.Windows.Forms;
	using OpenNETCF.Windows.Graphics;

	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.PictureBox pictureBox1;
		Shape shape;

		public Form1()
		{
			//
			// 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 )
		{
			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.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			// 
			// pictureBox1
			// 
			this.pictureBox1.Size = new System.Drawing.Size(240, 96);
			// 
			// Form1
			// 
			this.Controls.Add(this.pictureBox1);
			this.Menu = this.mainMenu1;
			this.MinimizeBox = false;
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>

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

		private void Form1_Load(object sender, System.EventArgs e)
		{
			// Obtain bitmap stream
			Stream st = Assembly.GetExecutingAssembly().GetManifestResourceStream("ShapedWindow.StopSign.bmp");
			// Create a new Shape object (this will load the bitmap and build the Shape (region) from it)
			shape = new Shape(st);
			// Set the same bitmap as an image - source for the pictureBox
			pictureBox1.Image = new Bitmap(st);
			// and resize it
			pictureBox1.Size = pictureBox1.Image.Size;
			// Set the form shape
			shape.Apply(this);
			pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
		}

		// Add some painting just for the fun of it
		private void pictureBox1_Paint(object sender, PaintEventArgs e)
		{
			Font fnt = new Font("Tahoma", 18, FontStyle.Bold );
			e.Graphics.DrawString("STOP", fnt, new SolidBrush(Color.DarkGray), 15, 32);
			e.Graphics.DrawString("STOP", fnt, new SolidBrush(Color.White), 13, 30);
			fnt.Dispose();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -