⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 vb精彩编程希望大家有用
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "多次剪贴板"
   ClientHeight    =   2235
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5340
   LinkTopic       =   "Form1"
   ScaleHeight     =   2235
   ScaleWidth      =   5340
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "全部清空"
      Height          =   495
      Left            =   1080
      TabIndex        =   4
      Top             =   1440
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "删除"
      Enabled         =   0   'False
      Height          =   495
      Left            =   1080
      TabIndex        =   3
      Top             =   840
      Width           =   1215
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   630
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   5340
      _ExtentX        =   9419
      _ExtentY        =   1111
      ButtonWidth     =   1640
      ButtonHeight    =   953
      Appearance      =   1
      _Version        =   393216
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   2400
      TabIndex        =   1
      Top             =   840
      Width           =   1215
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   4440
      Top             =   1320
   End
   Begin VB.ListBox List1 
      Height          =   600
      Left            =   2400
      TabIndex        =   0
      Top             =   1440
      Visible         =   0   'False
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
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
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const HWND_TOPMOST = -1
'定义常数的值
Dim cbtext As String
Dim i, j As Integer
Dim wd As Long
Private Sub Command1_Click()
    '删除指定条目
    List1.RemoveItem Val(Text1.Text - 1) '移除索引号对应的条目(索引号从0开始)
    Toolbar1.Buttons.Remove Val(Text1.Text) '移除对应的按钮
    Text1.Text = ""
End Sub
Private Sub Command2_Click()
    '清空所有条目
    For j = List1.ListCount To 1 Step 1
        List1.RemoveItem j - 1
        Toolbar1.Buttons.Remove j
    Next j '清空所有的条目
    i = 0
    cbtext = "" '初始化变量
End Sub
Private Sub Form_Load()
    '将本窗体置顶
    wd = SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
        SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Private Sub Text1_Change()
    If Val(Text1.Text) > 0 And Val(Text1.Text) <= List1.ListCount Then
        Command1.Enabled = True
    Else
        Command1.Enabled = False
    End If
End Sub
Private Sub Timer1_Timer()
    On Error Resume Next
    If Clipboard.GetText = cbtext Or Clipboard.GetText = "" Then
    '校验剪贴板的文字是否与前一次的重复且是否为空
        Exit Sub
    End If
    For j = 0 To List1.ListCount - 1
        If Clipboard.GetText = List1.List(j) Then Exit Sub
        '校验是否有重复的,如有则不必再次复制
    Next j
    cbtext = Clipboard.GetText '获得剪贴板的文字
    i = i + 1
    Toolbar1.Buttons.Add i, , Left(cbtext, 10) + "..."
    '把新复制到剪贴板的内容的前10个字符相当于中文5个字符作为摘要,
    ' 添加到工具栏的新按钮的标题上
    List1.AddItem cbtext, i - 1 '把新获得的内容通过List控件的AddItem方法添加进去
    'Form1.Height = 1000 * (i + 1 / 4) + 1000 '设置窗体高度
    Clipboard.Clear '清空剪贴板
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Clipboard.Clear
    Clipboard.SetText List1.List(Button.Index - 1) '把相应条目复制到剪贴板
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -