📄 frmmain.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 3 'Fixed Dialog
ClientHeight = 450
ClientLeft = 45
ClientTop = 45
ClientWidth = 3150
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 450
ScaleWidth = 3150
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer
Interval = 100
Left = 315
Top = 705
End
Begin VB.Frame Frame1
Height = 495
Left = 0
TabIndex = 0
Top = -75
Width = 3135
Begin VB.PictureBox pctPrg
Appearance = 0 'Flat
BackColor = &H00000000&
BorderStyle = 0 'None
FillColor = &H00008000&
ForeColor = &H0000FF00&
Height = 270
Left = 60
ScaleHeight = 18
ScaleMode = 3 'Pixel
ScaleWidth = 200
TabIndex = 1
Top = 150
Width = 3000
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'********************************************************************************
'* CPUUsage 1.0
'* ----------------
'*
'* This program is total FREEWARE.
'*
'* It use the registry to get the CPU usage in percent.
'*
'* You can also move the form without title bar and close it with the right button.
'*
'* Happy programming !
'*
'*
'********************************************************************************
' The CPUUsage object
Private CPU As New CPUUsage
Private Avg As Long ' Average of CPU Usage
Private Sum As Long
Private Index As Long
Private Sub Form_Load()
' First, open the "StartStat" key
CPU.InitCPUUsage
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Timer.Enabled = False
Set CPU = Nothing
Cancel = 0
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Form_MouseDown(Button, Shift, X, Y)
End Sub
Private Sub pctPrg_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Unload Me
End
End If
Call Form_MouseDown(Button, Shift, X, Y)
End Sub
Private Sub Timer_Timer()
'Get the CPU Usage every second
Dim tmp As Long
tmp = CPU.GetCPUUsage
Sum = Sum + tmp
Index = Index + 1
Avg = Int(Sum / Index)
'Draw the bar
pctPrg.Cls
pctPrg.Line (0, 0)-(tmp, 18), , BF
pctPrg.Line (Avg, 0)-(Avg, 18), &HFF
pctPrg.Line (Avg + 1, 0)-(Avg + 1, 18), &HFF
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim rc As Long
rc = ReleaseCapture
rc = SendMessage(hwnd, WM_NCLBUTTONDOWN, LP_HT_CAPTION, ByVal 0&)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -