大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
添加Microsoft Forms 2.0 控件,它是一组与vb一样的控件,backStyle属性可以设置为透明的。
创新互联专注于琼中黎族企业网站建设,自适应网站建设,商城建设。琼中黎族网站建设公司,为琼中黎族等地区提供建站服务。全流程按需求定制制作,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
设置文本框的 BackStyle 属性该属性可以取两个值,即0 和 1 。如果为 0 ,则是透明的。
该属性可以在属性窗口中设置,也可以通过代码设置。其格式为:
对象.BackStyle[=0 或 1]
1、将窗口的TransparencyKey属性设置成某一种颜色(在显示时,这种颜色会显示为透明),如:
Me.TransparencyKey = System.Drawing.Color.Red(可在属性窗口中指定或通过代码设置)
2、将Label的BackColor属性设置为与窗口的TransparencyKey属性相同的颜色,如:
Me.label1.BackColor = System.Drawing.Color.Red(可在属性窗口中指定或通过代码设置)
或
Me.label1.BackColor = Me.TransparencyKey(只能通过代码设置)
3、将Label的ForeColor属性设置为与窗口的TransparencyKey属性不相的颜色,如:
Me.label1.ForeColor = System.Drawing.Color.Blue(可在属性窗口中指定或通过代码设置)
这种功能读winform来说只有容器才能设置透明度,如form、panel类控件,其他的不是不可以,要重写背景参数,而且重写完了后与win7、Xp互不兼容,闪烁,并不提倡。.net的解决办法是wpf,控件可以设置opation属性,灵活控制透明度,并且后台静态刷新,因为他是xaml机制构造。
好东东!可惜我e文也不太好...给你翻译一点:
先在左上角把类给下载了,然后,使用方法----
This sample presents a small class that allows you to tile a bitmap into the background of a TextBox. Note that the technique only works on multi-line text boxes, as the drawing of single-line TextBoxes is done in a different way and cannot be easily overridden in code.
这例子向你展示怎么用一个类给textbox贴上背景图片。要注意的是,这种方法只能用在多行文本框上。至于单行文本框,要用另外一种方法,并且不是那么容易用代码实现的。
......(中间省略无数行)
The cTextBoxBackground class
To make this easier to use, I've wrapped the code up in a simple class. This class has the following methods:
为了让用着方便些,我把代码都打包到一个简单的类里面了。这个类有下面这些方法:
Attach(ByVal hWndA As Long)
Attaches the class to the multi-line text box with the specified hWnd. Don't call this method until you've set up the background picture first.
让类与多行文本框连接(Attach),需指定hWnd。你必须先设置好背景图片,才能call这个方法。
Detach()
Detaches from the class so the text box painting goes back to normal. Called automatically when the TextBox is destroyed.
取消连接,使文本框会到原来的模式。文本框被摧毁(例如unload窗体)时会自动执行。
SetBackdrop(pic As IPicture)
Sets the background bitmap from a standard VB picture object (for example, a StdPicture returned from LoadPicture or the picture returned by a PictureBox's Picture property.
用一个标准的vb图片对象(例如一个由LoadPicture()函数返回的StdPicture对象,或者PictureBox的Picture 属性)设置背景位图
TileArea(ByVal hdcTo As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long)
The bitmap tiling function is exposed to allow you to tile the bitmap onto any other objects with a hDC property. This is used in the second sample form in the demo to tile the background of the form.
这个方法能让你通过把位图贴到其它对象上,只要你能提供它的hDC属性。在示例里的第二个窗体有用这个方法贴窗体背景的例子。
TileOffsetX() As Long
Gets or Sets the initial X offset in the bitmap to start tiling from.
返回或者设置位图绘制起始点的X坐标。
TileOffsetY() As Long
Gets or Sets the initial Y offset in the bitmap to start tiling from.
返回或者设置位图绘制起始点的Y坐标。
To use it, first add a TextBox to a form, set it to multi-line mode and then create a form level instance of the cTextBoxBackground class (here I'm assuming it's called m_cLargeTextBoxBack). Then set the background picture and attach it to the text box as follows:
使用的时候,先放上一个TextBox,设置为multi-line模式;然后声明一个模块级的cTextBoxBackground实例(我假定是那实例叫m_cLargeTextBoxBack)。最后像下面那样设置背景图片并把它贴到TextBox上:
Set m_cLargeTextBoxBack = New cTextBoxBackground
m_cLargeTextBoxBack.SetBackdrop LoadPicture(App.Path "\back.bmp")
m_cLargeTextBoxBack.Attach txtTest.hwnd
要考四级了,算是练习吧...555...祝我好运...