Leisureeen

导航

XYShowLabel

‎August ‎12, ‎2018那天下午写的一个简单的VB小程序,主要用于电脑录屏时显示预先设置好的文本,就像电影字幕一样。

需要提前将文本准备在应用程序目录下的XYShowLabel.txt文件中,按方向键右(→)可以往下翻。

 

主界面窗体文件(main.frm):

VERSION 5.00
Begin VB.Form main 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   1215
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   13170
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1215
   ScaleWidth      =   13170
   StartUpPosition =   2  '屏幕中心
   Begin VB.Label out 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "User:Leisureeen"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   48
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   13095
   End
End
Attribute VB_Name = "main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private outTmp As String

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    On Error Resume Next
    Dim capTmp As String
    If KeyCode = 37 Then
        capTmp = VBA.InputBox("Please Set the Title.", "Setting", main.Caption)
        If Len(capTmp) > 1 Then main.Caption = capTmp
    ElseIf KeyCode = 39 Then
        Line Input #1, outTmp
        If out.Caption <> outTmp Then out.Caption = outTmp
    End If
End Sub

Private Sub Form_Load()
    Dim colorTmp As Long
    On Error Resume Next
    If Dir(App.Path & "\XYShowLabel.txt") = "" Then
        MsgBox "Please ADD a file named ""XYShowLabel.txt"".", 16, "ERROR"
        End
    End If
    Me.BackColor = RGB(0, 38, 0)
    SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1
    Me.Caption = "Designer:Leisureeen"
    colorTmp = GetWindowLong(Me.hwnd, -20)
    colorTmp = colorTmp Or &H80000
    SetWindowLong Me.hwnd, -20, colorTmp
    SetLayeredWindowAttributes Me.hwnd, Me.BackColor, 38, 1
    Open App.Path & "\XYShowLabel.txt" For Input As #1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Close
    End
End Sub

 

posted on 2020-04-16 20:59  Leisureeen  阅读(238)  评论(0编辑  收藏  举报

JS