用户自定义控件透明文本框Word文件下载.docx

上传人:b****6 文档编号:18051729 上传时间:2022-12-13 格式:DOCX 页数:13 大小:19.99KB
下载 相关 举报
用户自定义控件透明文本框Word文件下载.docx_第1页
第1页 / 共13页
用户自定义控件透明文本框Word文件下载.docx_第2页
第2页 / 共13页
用户自定义控件透明文本框Word文件下载.docx_第3页
第3页 / 共13页
用户自定义控件透明文本框Word文件下载.docx_第4页
第4页 / 共13页
用户自定义控件透明文本框Word文件下载.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

用户自定义控件透明文本框Word文件下载.docx

《用户自定义控件透明文本框Word文件下载.docx》由会员分享,可在线阅读,更多相关《用户自定义控件透明文本框Word文件下载.docx(13页珍藏版)》请在冰豆网上搜索。

用户自定义控件透明文本框Word文件下载.docx

///(C)2003BobBradley/ZBobb@

/summary>

///

publicclassAlphaBlendTextBox:

System.Windows.Forms.TextBox

{

#regionprivatevariables

privateuPictureBoxmyPictureBox;

privateboolmyUpToDate=false;

privateboolmyCaretUpToDate=false;

privateBitmapmyBitmap;

privateBitmapmyAlphaBitmap;

privateintmyFontHeight=10;

privateSystem.Windows.Forms.TimermyTimer1;

privateboolmyCaretState=true;

privateboolmyPaintedFirstTime=false;

privateColormyBackColor=Color.White;

privateintmyBackAlpha=10;

///Requireddesignervariable.

privateSystem.ComponentModel.Containercomponents=null;

#endregion//endprivatevariables

#regionpublicmethodsandoverrides

publicAlphaBlendTextBox()

//ThiscallisrequiredbytheWindows.FormsFormDesigner.

InitializeComponent();

//TODO:

AddanyinitializationaftertheInitializeComponentcall

this.BackColor=myBackColor;

this.SetStyle(ControlStyles.UserPaint,false);

this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);

this.SetStyle(ControlStyles.DoubleBuffer,true);

myPictureBox=newuPictureBox();

this.Controls.Add(myPictureBox);

myPictureBox.Dock=DockStyle.Fill;

}

protectedoverridevoidOnResize(EventArgse)

base.OnResize(e);

this.myBitmap=newBitmap(this.ClientRectangle.Width,this.ClientRectangle.Height);

//(this.Width,this.Height);

this.myAlphaBitmap=newBitmap(this.ClientRectangle.Width,this.ClientRectangle.Height);

myUpToDate=false;

this.Invalidate();

//SomeoftheseshouldbemovedtotheWndProclater

protectedoverridevoidOnKeyDown(KeyEventArgse)

base.OnKeyDown(e);

protectedoverridevoidOnKeyUp(KeyEventArgse)

base.OnKeyUp(e);

protectedoverridevoidOnKeyPress(KeyPressEventArgse)

base.OnKeyPress(e);

protectedoverridevoidOnMouseUp(MouseEventArgse)

base.OnMouseUp(e);

protectedoverridevoidOnGiveFeedback(GiveFeedbackEventArgsgfbevent)

base.OnGiveFeedback(gfbevent);

protectedoverridevoidOnMouseLeave(EventArgse)

//foundthiscodetofindthecurrentcursorlocation

//at

PointptCursor=Cursor.Position;

Formf=this.FindForm();

ptCursor=f.PointToClient(ptCursor);

if(!

this.Bounds.Contains(ptCursor))

base.OnMouseLeave(e);

protectedoverridevoidOnChangeUICues(UICuesEventArgse)

base.OnChangeUICues(e);

//--

protectedoverridevoidOnGotFocus(EventArgse)

base.OnGotFocus(e);

myCaretUpToDate=false;

myTimer1=newSystem.Windows.Forms.Timer(ponents);

myTimer1.Interval=(int)win32.GetCaretBlinkTime();

// 

usuallyaround500;

myTimer1.Tick+=newEventHandler(myTimer1_Tick);

myTimer1.Enabled=true;

protectedoverridevoidOnLostFocus(EventArgse)

base.OnLostFocus(e);

myTimer1.Dispose();

//-- 

protectedoverridevoidOnFontChanged(EventArgse)

if(this.myPaintedFirstTime)

base.OnFontChanged(e);

this.SetStyle(ControlStyles.UserPaint,true);

myFontHeight=GetFontHeight();

protectedoverridevoidOnTextChanged(EventArgse)

base.OnTextChanged(e);

protectedoverridevoidWndProc(refMessagem)

base.WndProc(refm);

//needtorewriteasabigswitch

if(m.Msg==win32.WM_PAINT)

myPaintedFirstTime=true;

myUpToDate||!

myCaretUpToDate)

GetBitmaps();

myUpToDate=true;

myCaretUpToDate=true;

if(myPictureBox.Image!

=null)myPictureBox.Image.Dispose();

myPictureBox.Image=(Image)myAlphaBitmap.Clone();

elseif(m.Msg==win32.WM_HSCROLL||m.Msg==win32.WM_VSCROLL)

elseif(m.Msg==win32.WM_LBUTTONDOWN

||m.Msg==win32.WM_RBUTTONDOWN

||m.Msg==win32.WM_LBUTTONDBLCLK

||m.Msg==win32.WM_MOUSELEAVE 

///****

elseif(m.Msg==win32.WM_MOUSEMOVE)

if(m.WParam.ToInt32()!

=0) 

//shiftkeyorotherbuttons

//System.Diagnostics.Debug.WriteLine("

Pro:

"

+m.Msg.ToString("

X"

));

///Cleanupanyresourcesbeingused.

protectedoverridevoidDispose(booldisposing)

if(disposing)

//this.BackColor=Color.Pink;

if(components!

=null)

components.Dispose();

base.Dispose(disposing);

#endregion 

//endpublicmethodandoverrides

#regionpublicpropertyoverrides

publicnewBorderStyleBorderStyle

get{returnbase.BorderStyle;

set

base.BorderStyle=value;

this.myBitmap=null;

this.myAlphaBitmap=null;

publicnewColorBackColor

get

returnColor.FromArgb(base.BackColor.R,base.BackColor.G,base.BackColor.B);

myBackColor=value;

base.BackColor=value;

publicoverrideboolMultiline

get{returnbase.Multiline;

base.Multiline=value;

//endpublicpropertyoverrides

#regionprivatefunctionsandclasses

privateintGetFontHeight()

Graphicsg=this.CreateGraphics();

SizeFsf_font=g.MeasureString("

this.Font);

g.Dispose();

return(int)sf_font.Height;

privatevoidGetBitmaps()

if(myBitmap==null

||myAlphaBitmap==null

||myBitmap.Width!

=Width

||myBitmap.Height!

=Height

||myAlphaBitmap.Width!

||myAlphaBitmap.Height!

=Height)

myBitmap=null;

myAlphaBitmap=null;

if(myBitmap==null)

myBitmap=newBitmap(this.ClientRectangle.Width,this.ClientRectangle.Height);

//(Width,Height);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1