|
'frm
- Option Explicit
- Private Sub Form_Load()
- Dim strTxtSource As String
- Dim lngArrayUbound As Long
- m_lngTxtTop = picShow.Height
- lblCredits = App.ProductName & " - Credits"
- lblCompany = App.CompanyName
- lblDescription = App.FileDescription
- lbVersion = "Version : " & App.Major & "." & App.Minor & "." & App.Revision
- strTxtSource = LoadText(App.Path & "\Credits.txt")
- m_astrTxtLine = Split(strTxtSource, vbCrLf)
- lngArrayUbound = UBound(m_astrTxtLine)
- ReDim Preserve m_astrTxtLine(lngArrayUbound)
- End Sub
- Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- lbClose.ForeColor = RGB(119, 60, 0)
- End Sub
- Private Sub lbClose_Click()
- Unload Me
- End Sub
- Private Sub lbClose_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- lbClose.ForeColor = RGB(255, 128, 10)
- End Sub
- Private Sub lblPause_Click()
- tmrUpdate.Enabled = Not tmrUpdate.Enabled
- If tmrUpdate.Enabled = False Then
- lblPause.ForeColor = RGB(255, 128, 10)
- Else
- lblPause.ForeColor = RGB(119, 60, 0)
- End If
- End Sub
- Private Sub PicShow_Click()
- lblPause_Click
- End Sub
- Private Sub tmrUpdate_Timer()
- Dim i As Long
- Dim lngTxtTop As Long
- picShow.Cls
- lngTxtTop = m_lngTxtTop
- For i = 0 To UBound(m_astrTxtLine)
- If lngTxtTop > -50 And lngTxtTop < picShow.Height Then
- SendCredits picShow, m_astrTxtLine(i), 33, lngTxtTop, vbBlack, RGB(205, 128, 0), vbBlack, 1 / 6
- End If
- lngTxtTop = lngTxtTop + picShow.TextHeight(m_astrTxtLine(i))
- Next
- '到达顶部
- If m_lngTxtTop + 20 < -picShow.TextHeight("A") * UBound(m_astrTxtLine) Then
- m_lngTxtTop = picShow.Height
- End If
- m_lngTxtTop = m_lngTxtTop - 1
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim intRet As Integer
- Erase m_astrTxtLine
- '是否复制作者网址
- intRet = MsgBox("( PLEASE GIVE FEEDBACK ) to improve this code.Click 'Ok' to copy the site address to your clipboard", vbInformation + vbOKCancel, "Please Give FeedBack")
- If intRet = vbOK Then
- Clipboard.SetText ("http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=58396&lngWId=1")
- End If
- End Sub
复制代码
'mod
- Option Explicit
- Public m_lngTxtTop As Long '存储Text Top值
- Public m_astrTxtLine() As String '存放文本行
- 'DrawText将文本描绘到指定的矩形中
- '返回值
- 'Long,描绘文字的高度
- '参数表
- '参数 类型及说明
- 'hdc Long,欲在其中显示文字的一个设备场景的句柄
- 'lpStr String,欲描绘的文本字串
- 'nCount Long,欲描绘的字符数量。如果要描绘整个字串(直到空中止符),则可将这个参数设为-1
- 'lpRect RECT,指定用于绘图的一个格式化矩形(采用逻辑坐标)
- 'wFormat Long,一个标志位数组,决定了以何种形式执行绘图。
- Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, _
- ByVal lpStr As String, _
- ByVal nCount As Long, _
- lpRect As RECT, _
- ByVal wFormat As Long) _
- As Long
- Private Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Private Const DT_NOPREFIX = &H800 '通常,函数认为 & 字符表示应为下一个字符加上下划线。该标志禁止这种行为
- Public Function LoadText(FromFile As String) As String
- Dim strTxt As String
- Dim intFileNum As Integer
- On Error GoTo Handle
- If Dir(FromFile) = vbNullString Then
- MsgBox "The file " & FromFile & " not found. Check if the file is Currently exists.", vbCritical, "Sorry"
- Exit Function
- End If
- intFileNum = FreeFile
- Open FromFile For Input As #intFileNum
- strTxt = StrConv(InputB(LOF(intFileNum), #intFileNum), vbUnicode)
- Close #intFileNum
- LoadText = strTxt
- Exit Function
- Handle:
- MsgBox "Error " & Err.Number & vbCrLf & Err.Description, vbCritical, "Error"
- End Function
- Public Function GetShade(ByVal StartCol As Long, ByVal EndCol As Long, ByVal ColDepth As Double) As Long
- Dim sRate As Double
- Dim cBlue As Long, cGreen As Long, cRed As Long
- Dim sBlue As Long, sGreen As Long, sRed As Long
- sRate = ColDepth
- GetRGB EndCol, sRed, sGreen, sBlue '获取尾部颜色rgb值
- GetRGB StartCol, cRed, cGreen, cBlue '获取手部颜色rgb值
- cRed = cRed + (sRed - cRed) * sRate
- cGreen = cGreen + (sGreen - cGreen) * sRate '计算新渐变颜色
- cBlue = cBlue + (sBlue - cBlue) * sRate
- GetShade = RGB(Abs(cRed), Abs(cGreen), Abs(cBlue))
- End Function
- Private Sub GetRGB(ByVal LngCol As Long, R As Long, G As Long, B As Long)
- R = LngCol Mod 256
- G = (LngCol And vbGreen) / 256
- B = (LngCol And vbBlue) / 65536
- End Sub
- Public Function SendCredits(PicBox As PictureBox, Txt As String, _
- ByVal X As Integer, ByVal Y As Integer, _
- Optional StartCol As Long = 0, Optional MidCol As Long = &H1B207, _
- Optional EndCol As Long = 0, Optional ByVal cRegion As Double)
- Dim hLength As Integer
- Dim DrawCol As Long
- Dim RC As RECT
- hLength = PicBox.Height * cRegion '等分PIC高度,这里是1/6
- If Y <= hLength Then
- '顶部文字淡入
- DrawCol = GetShade(MidCol, EndCol, (hLength - Y) / (hLength + 20)) '获取渐变色
- ElseIf Y <= PicBox.Height And Y >= PicBox.Height * (1 - cRegion) Then '要大于其余5/6
- '底部文字淡出
- DrawCol = GetShade(StartCol, MidCol, (PicBox.Height - Y) / hLength) '获取渐变色
- Else
- DrawCol = MidCol '中部文字
- End If
- With RC
- .Left = X
- .Top = Y
- .Right = PicBox.Width
- .Bottom = PicBox.Height
- End With
- PicBox.ForeColor = DrawCol '设置输出前景色
- DrawText PicBox.hdc, Txt, -1, RC, DT_NOPREFIX
- End Function
复制代码
评论,颜色幻数令我眼花,CPU占用稍微高些,N多代调试程序选这个软柿子吃了。 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|