资源简介
一个背景透明Textbox控件的源代码,很不错的东西
代码片段和文件信息
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace ZBobb
{
///
/// AlphaBlendTextBox: A .Net textbox that can be translucent to the background.
/// (C) 2003 Bob Bradley / ZBobb@hotmail.com
///
///
public class AlphaBlendTextBox : System.Windows.Forms.TextBox
{
#region private variables
private uPictureBox myPictureBox;
private bool myUpToDate = false;
private bool myCaretUpToDate = false;
private Bitmap myBitmap;
private Bitmap myAlphaBitmap;
private int myFontHeight = 10;
private System.Windows.Forms.Timer myTimer1;
private bool myCaretState = true;
private bool myPaintedFirstTime = false;
private Color myBackColor = Color.White;
private int myBackAlpha = 10;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
#endregion // end private variables
#region public methods and overrides
public AlphaBlendTextBox()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
this.BackColor = myBackColor;
this.Setstyle(Controlstyles.UserPaintfalse);
this.Setstyle(Controlstyles.AllPaintingInWmPainttrue);
this.Setstyle(Controlstyles.DoubleBuffertrue);
myPictureBox = new uPictureBox();
this.Controls.Add(myPictureBox);
myPictureBox.Dock = Dockstyle.Fill;
}
protected override void onresize(EventArgs e)
{
base.onresize (e);
this.myBitmap = new Bitmap(this.ClientRectangle.Widththis.ClientRectangle.Height);//(this.Widththis.Height);
this.myAlphaBitmap = new Bitmap(this.ClientRectangle.Widththis.ClientRectangle.Height);//(this.Widththis.Height);
myUpToDate = false;
this.Invalidate();
}
//Some of these should be moved to the WndProc later
protected override void onkeydown(KeyEventArgs e)
{
base.onkeydown (e);
myUpToDate = false;
this.Invalidate();
}
protected override void onkeyup(KeyEventArgs e)
{
base.onkeyup (e);
myUpToDate = false;
this.Invalidate();
}
protected override void onkeypress(KeyPressEventArgs e)
{
base.onkeypress (e);
myUpToDate = false;
this.Invalidate();
}
protected override void onmouseup(MouseEventArgs e)
{
base.onmouseup (e);
this.Invalidate();
}
protected override void OnGiveFeedback(GiveFeedbackEventArgs gfbevent)
{
base.OnGiveFeedback (gfbevent);
myUpToDate = false;
this.Invalidate();
}
protected override void onmouseleave(EventArgs e)
{
//found this code to find the current cursor location
//at http://www.syncfusion.com/FAQ/WinForms/FAQ_c50c.asp#q597q
Point ptCursor = Cursor
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4975 2003-06-24 20:51 ABTestCS\ABTestCS.csproj
文件 1884 2003-06-24 21:28 ABTestCS\ABTestCS.csproj.user
文件 1078 2003-06-23 09:00 ABTestCS\App.ico
文件 2426 2003-06-23 09:00 ABTestCS\AssemblyInfo.cs
文件 8481 2003-06-23 15:29 ABTestCS\bob_smaller1.jpg
文件 7340 2003-06-24 21:08 ABTestCS\Form1.cs
文件 26898 2003-06-24 21:08 ABTestCS\Form1.resx
文件 901 2003-06-22 17:54 ABTestVB\ABTestVB.sln
文件 4426 2003-06-24 21:27 ABTestVB\ABTestVB.vbproj
文件 1974 2003-06-24 21:27 ABTestVB\ABTestVB.vbproj.user
文件 1044 2003-06-22 17:54 ABTestVB\AssemblyInfo.vb
文件 9993 2003-06-24 21:27 ABTestVB\Form1.resx
文件 2614 2003-06-24 21:27 ABTestVB\Form1.vb
文件 13273 2003-06-24 21:24 AlphaBlendTextBox.cs
文件 4844 2003-06-22 18:22 AlphaBlendTextBox.csproj
文件 1804 2003-06-24 21:28 AlphaBlendTextBox.csproj.user
文件 1733 2002-01-30 00:04 AlphaBlendTextBox.resx
文件 1425 2003-06-23 09:07 AlphaBlendTextBox.sln
文件 2590 2003-06-22 22:49 AssemblyInfo.cs
文件 539 2003-06-24 21:31 ReadMe.txt
文件 3044 2003-06-24 21:25 win32.cs
评论
共有 条评论