摘要载入中…    请稍等…












内容载入中…    请稍等…

如长时间看不到内容,请关闭浏览器,重新打开此页!

芯友首页 应用软件 编程开发 网络硬件 资源下载 动漫音乐 精美图库 芯友论坛 视频教程 电脑技术QQ群:72845454
 ★★photoshop学友-史上最强播放器★★
 位置:编程开发>VB>VB窗体文章
◎→ 本类最新
VB6制作Win98风格的工具栏
动态加载ActiveX控件漫谈
实现窗口图像缩放、滚动技巧
VB中处理长列表框项的两种方法
VB应用程序中的工具提示和状态显
VB实现窗口的弹出式菜单
VB实现按钮浮动效果
◎→相关资源
C语言入门视频教程
C#编程WinForm入门视频
Asp.net入门视频教程下载
VC++编程视频教程下载
VB窗体文章
HTML入门教程
VB基础视频教程
VB窗体文章
VB文件文章
VB数据库文章
VB-API文章
VB控制文章
◎→ 热门资源
在VB中让控件大小和位置随着表单
c在VB中利用API实现窗体的平滑显
在ListBox适当设定水平滚动条的宽
运行中隐藏 显示窗口标题栏
运行时改变控件大小的两种方法
用VisualBasic制作半透明窗体
用Visual Basic设计三维图形按钮

如何做出跑馬燈效果的 TextBox


日期:2008-10-20 17:42:48    来源:互联网
   
 ·API实现完美的图片出现效果 ·怎样得到文本框(TextBox)中的文本行数?
 ·在ListBox适当设定水平滚动条的宽度
如何做出跑馬燈效果的 TextBox


老怪試作:

VERSION 5.00
Begin VB.Form Form1
Caption = "Marquee"
ClientHeight = 3960
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3960
ScaleWidth = 4680
StartUpPosition = 3 '系統預設值
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "跑馬燈結束"
Height = 495
Left = 2640
TabIndex = 5
Top = 3360
Width = 1215
End
Begin VB.Timer Timer1
Left = 2160
Top = 3480
End
Begin VB.CommandButton Command1
Caption = "跑馬燈開始"
Height = 495
Left = 840
TabIndex = 2
Top = 3360
Width = 1215
End
Begin VB.TextBox Text2
Height = 1215
Left = 840
MultiLine = -1 'True
ScrollBars = 2 '垂直捲軸
TabIndex = 1
Top = 1920
Width = 3135
End
Begin VB.TextBox Text1
BackColor = &H80000018&
Height = 375
Left = 1200
TabIndex = 0
Top = 360
Width = 2895
End
Begin VB.Label Label4
Alignment = 2 '靠中對齊
Caption = "請輸入跑馬燈文字"
Height = 375
Left = 1320
TabIndex = 4
Top = 1200
Width = 2295
End
Begin VB.Label Label2
Caption = "Text 跑馬燈"
Height = 375
Left = 120
TabIndex = 3
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'宣告要在 Text1 裏顯示的跑馬燈字串變數
Dim TString As String

Private Sub Command1_Click()
'宣告儲存 Text1 字串長度的變數
Dim TWidth As Long

Command2.Enabled = True
'啟動 Timer 顯示跑馬燈
Timer1.Enabled = True
Command1.Enabled = False

'text2 裏必須輸入跑馬燈字串
If Text2.Text = "" Then
MsgBox "請輸入跑馬燈文字"
'沒有輸入就按下 Command2 跑馬燈結束鈕
Command2_Click
Exit Sub
End If

'統計 Text1Box 裏到底放的下幾個字
Do While TextWidth(Space(TWidth)) <= Text1.Width
TWidth = TWidth + 1
Loop

'設定跑馬燈字串為 Text1 寬度個空白
'加原輸入的 跑馬燈文字
TString = Space(TWidth) + Text2.Text

End Sub

Private Sub Command2_Click()
Text1.Text = ""

Command1.Enabled = True

Command2.Enabled = False
'關閉跑馬燈顯示
Timer1.Enabled = False

Text2.SetFocus
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 200
Command2.Enabled = False

'將各元件 Font 統一,利於計算字串寬度
Text1.Font = Me.Font
Text2.Font = Me.Font

Me.Show

Text2.SetFocus

End Sub

Private Sub Timer1_Timer()
'開始頡取跑馬燈字串之位置指標
Static TPos As Long

'如果位置指標越過了整個字串
If TPos > Len(TString) Then
'把位置指標移到最開頭
TPos = 1
Else
'把位置指標移到下一個字
TPos = TPos + 1
End If

'逐字顯示跑馬燈字串
Text1.Text = Mid(TString, TPos)

End Sub
 [1]

用API函数改进ListView控件的显示效果

利用API 使Text框只读

快速读取TextBox第N行的数据

--->JetAudio 7.0.2 Build 3010Plus VX┊带声音增强效果的播放器┊英文绿色特别版
--->MoleBox Pro V2.63┊将应用程序和所有数据全部打包到一个exe┊汉化绿色特别版
--->MoleBox Pro V2.3.3.1416 破解补丁
--->MoleBox Pro V2.30.1264 破解补丁
--->Mailbox Guard V1.7
Tags:  效果 Text Box

芯友网版权所有 1999-2006 | 著作权与商标声明 | 法律声明 | 服务条款 | 隐私声明 | 联系我们