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

📄 主窗体.frm

📁 VB多线程源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form 主窗体 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "多线程示例"
   ClientHeight    =   1950
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5115
   Icon            =   "主窗体.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   1950
   ScaleWidth      =   5115
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton 结束线程按钮 
      Caption         =   "结束线程"
      Enabled         =   0   'False
      Height          =   375
      Left            =   3600
      TabIndex        =   7
      Top             =   840
      Width           =   1335
   End
   Begin VB.CommandButton 创建线程按钮 
      Caption         =   "创建线程"
      Height          =   375
      Left            =   3600
      TabIndex        =   2
      Top             =   240
      Width           =   1335
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "共同:"
      Height          =   180
      Left            =   240
      TabIndex        =   6
      Top             =   1440
      Width           =   540
   End
   Begin VB.Label tr 
      BackColor       =   &H00E0E0E0&
      Caption         =   "0"
      Height          =   180
      Left            =   960
      TabIndex        =   5
      Top             =   1440
      Width           =   2370
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "线程2:"
      Height          =   180
      Left            =   240
      TabIndex        =   4
      Top             =   720
      Width           =   630
   End
   Begin VB.Label tr2 
      BackColor       =   &H00E0E0E0&
      Height          =   180
      Left            =   960
      TabIndex        =   3
      Top             =   720
      Width           =   2370
   End
   Begin VB.Label tr1 
      BackColor       =   &H00E0E0E0&
      Height          =   180
      Left            =   960
      TabIndex        =   1
      Top             =   315
      Width           =   2370
   End
   Begin VB.Label l 
      AutoSize        =   -1  'True
      Caption         =   "线程1:"
      Height          =   180
      Left            =   240
      TabIndex        =   0
      Top             =   315
      Width           =   630
   End
End
Attribute VB_Name = "主窗体"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()
    Call InitializeCriticalSection(g_cs)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    结束线程
    Call DeleteCriticalSection(g_cs)
End Sub

Public Sub 显示结束标语()
    tr = tr & ":线程结束"
End Sub

Private Sub 创建线程按钮_Click()
    创建线程
    启动线程
    按钮切换 False
End Sub

Private Sub 结束线程按钮_Click()
    结束线程
    按钮切换 True
End Sub

Private Sub 按钮切换(Enabled As Boolean)
    创建线程按钮.Enabled = Enabled
    结束线程按钮.Enabled = Not Enabled
End Sub

⌨️ 快捷键说明

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