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

📄 form1.frm

📁 很好的教程原代码!
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4230
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5925
   LinkTopic       =   "Form1"
   ScaleHeight     =   4230
   ScaleWidth      =   5925
   StartUpPosition =   3  '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'API函数声明
Private Declare Function CreateSolidBrush Lib "gdi32" _
    (ByVal crColor As Long) As Long
Private Declare Function FillRect Lib "user32" _
    (ByVal hdc As Long, lpRect As RECT, _
    ByVal hBrush As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
    (ByVal hObject As Long) As Long
'相关常量声明
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

'窗体的Paint事件
Private Sub Form_Paint()
    Dim Color As Integer
    Dim hBrush As Long
    Dim OldMode As Integer
    Dim RetVal As Integer
    Dim StepSize As Integer
    Dim X As Integer
    Dim FillArea As RECT
 
    OldMode% = Me.ScaleMode
    Me.ScaleMode = 3
    StepSize% = 1 + Me.ScaleHeight / 50
    Color% = 255
    FillArea.Left = 0
    FillArea.Right = Me.ScaleWidth
    FillArea.Top = 0
    FillArea.Bottom = StepSize%
    For X% = 1 To 80
        '创建刷子句柄
        hBrush = CreateSolidBrush(RGB(0, 0, Color%))
        '用刷子填充
        RetVal% = FillRect(Me.hdc, FillArea, hBrush)
        '删除刷子
        RetVal% = DeleteObject(hBrush)
        Color% = Color% - 4
        If Color% < 0 Then Color% = 0
        FillArea.Top = FillArea.Bottom
        FillArea.Bottom = FillArea.Bottom + StepSize%
    Next
    Me.ScaleMode = OldMode%
End Sub

⌨️ 快捷键说明

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