WinCE5.0下实现透明背景按钮(.net C#) 个人实验
参考了WinCE5.0下实现透明背景按钮(.net C#)这篇文章后,本着不模仿的态度去做,结果发现还是原先作者的思路比较好,自己的做法
虽然比较简单当时图片得做很多张,效果其实也差不多,而且可维护性并不强,先把我自己做的贴出来。
希望自己多敲敲,能找出更简单的方案来
目录试图:
效果:
直接贴代码:
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;
using System.Reflection;
namespace whiteButton2
{
public partial class Form1 : Form
{
private string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);//获取PDA路径
private Bitmap bg, title;//
public Form1()
{
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;
this.ControlBox = false;
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bg = new Bitmap(currentPath + @"\Resources\bg293.jpg");
title = new Bitmap(currentPath + @"\Resources\title.jpg");
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics graphics;
graphics = e.Graphics;
graphics.DrawImage(bg,0,0);
graphics.DrawImage(title,0,0);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
//各类事件及方法
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
}
private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
}
private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
}
}
}
Form1.Designer.cs界面代码:
namespace whiteButton2
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.MainMenu mainMenu1;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Wind
补充:软件开发 , C# ,