当前位置:编程学习 > VB >>

如何美化Textbox

代码. --------------------编程问答-------------------- 一般美化:
Private Sub Form_Load()
    Timer1.Interval = 200
End Sub

Private Sub Timer1_Timer()
    Static i As Long
    Text1.BackColor = QBColor(i)
    i = i + 1
    If i Mod 15 = 0 Then i = 0
End Sub
--------------------编程问答-------------------- 哇,靠,好像闪光灯一样. --------------------编程问答-------------------- 一个文本框你还想如何美化? --------------------编程问答-------------------- 改变边框的色 --------------------编程问答-------------------- 在文本框里面写上“漂亮”两个字就可以了。 --------------------编程问答--------------------
引用 5 楼 nxslwh 的回复:
在文本框里面写上“漂亮”两个字就可以了。
--------------------编程问答-------------------- 一般来说,XP风格的单线条边框加上渐变背景就不错了吧:) --------------------编程问答-------------------- 你可以试试 Codejock Xtreme Suite Pro --------------------编程问答--------------------
引用 5 楼 nxslwh 的回复:
在文本框里面写上“漂亮”两个字就可以了。

高!
如果是VB.NET,可以使用WPF。VB要麻烦一些,先创建一个自定义控件里,在控件里放置一个文本框控件,然后复制以下代码,最后在Form添加该自定义控件来代替标准的文本框控件。

Option Explicit

Private Sub UserControl_Initialize()
    UserControl.BackColor = 0
    UserControl.ScaleMode = vbPixels
    Text1.BorderStyle = 0
End Sub

Private Sub UserControl_Resize()
    Text1.Move 1, 1, UserControl.ScaleWidth - 2, UserControl.ScaleHeight - 2
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    Text1.Text = PropBag.ReadProperty("Text")
    UserControl.BackColor = PropBag.ReadProperty("BorderColor")
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("Text", Text1.Text)
    Call PropBag.WriteProperty("BorderColor", UserControl.BackColor)
End Sub

Public Property Get Text() As String
    Text = Text1.Text
End Property
Public Property Let Text(ByVal New_Value As String)
    Text1.Text = New_Value
    UserControl.PropertyChanged "Text"
End Property

Public Property Get BorderColor() As OLE_COLOR
    BorderColor = UserControl.BackColor
End Property
Public Property Let BorderColor(ByVal New_Value As OLE_COLOR)
    UserControl.BackColor = New_Value
    UserControl.PropertyChanged "BorderColor"
End Property
--------------------编程问答-------------------- 看不明白. --------------------编程问答-------------------- --------------------编程问答-------------------- 这个例子美化RICHTEXTBOX,自己看看,还可以的



Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const BS_CENTER& = &H300&
Private Const BS_LEFT& = &H100&
Private Const BS_RIGHT& = &H200&
Private Const BS_TOP& = &H400&
Private Const GWL_STYLE& = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = &H20&
Private Const WS_THICKFRAME = &H40000
Private Const WS_BORDER = &H400000
Private Const WS_EX_CLIENTEDGE = &H200&

'API Calls
Private Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Const SWP_DRAWFRAME = &H20
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE



Private Sub Command1_Click()
Dim tmpValue&, ret&
Dim Align&
'Check if the state is checked

tmpValue& = (GetWindowLong&(Text1.hwnd, GWL_STYLE) Or WS_THICKFRAME) And Not WS_BORDER
ret& = SetWindowLong&(Text1.hwnd, GWL_STYLE, tmpValue&)
SetWindowPos Text1.hwnd, Me.hwnd, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_DRAWFRAME
Text1.Refresh
End Sub

--------------------编程问答-------------------- 再补充一下,也可以美化TXETBOX,就不知道是要美化。 --------------------编程问答-------------------- 建议你用richtext 吧 这个好美化 --------------------编程问答--------------------
引用 5 楼 nxslwh 的回复:
在文本框里面写上“漂亮”两个字就可以了。
支持一下! --------------------编程问答-------------------- 自己做个jpg然后在上面拉个textbox,再设置它的边框为none等等。。
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,