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

📄 form2.frm

📁 vb程序实现的是一个动态漂亮红灯笼
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   BorderStyle     =   0  'None
   Caption         =   "Form2"
   ClientHeight    =   1185
   ClientLeft      =   7590
   ClientTop       =   5850
   ClientWidth     =   1665
   Icon            =   "form2.frx":0000
   LinkTopic       =   "Form2"
   Picture         =   "form2.frx":2C6A
   ScaleHeight     =   1185
   ScaleWidth      =   1665
   ShowInTaskbar   =   0   'False
   Begin VB.PictureBox Picture3 
      Height          =   255
      Left            =   1080
      Picture         =   "form2.frx":3C06
      ScaleHeight     =   195
      ScaleWidth      =   195
      TabIndex        =   3
      Top             =   720
      Visible         =   0   'False
      Width           =   255
   End
   Begin VB.PictureBox Picture2 
      Height          =   255
      Left            =   1080
      Picture         =   "form2.frx":4AE2
      ScaleHeight     =   195
      ScaleWidth      =   195
      TabIndex        =   2
      Top             =   240
      Visible         =   0   'False
      Width           =   255
   End
   Begin VB.PictureBox Picture1 
      Height          =   255
      Left            =   600
      Picture         =   "form2.frx":59D7
      ScaleHeight     =   195
      ScaleWidth      =   315
      TabIndex        =   1
      Top             =   240
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.PictureBox Picture0 
      Height          =   375
      Left            =   240
      Picture         =   "form2.frx":69C7
      ScaleHeight     =   315
      ScaleWidth      =   195
      TabIndex        =   0
      Top             =   120
      Visible         =   0   'False
      Width           =   255
   End
   Begin VB.Timer Timer1 
      Left            =   240
      Top             =   600
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

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

Dim My_Picture(0 To 3) As Picture
Dim Times As Integer
Dim hRgn As Long
Dim MouseDown As Boolean
Dim TmpX, TmpY As Single

Private Sub Form_DblClick()
Unload Form2
Unload Form1
End Sub

Private Sub Form_Load()

Set My_Picture(0) = Picture0.Picture
Set My_Picture(1) = Picture1.Picture
Set My_Picture(2) = Picture2.Picture
Set My_Picture(3) = Picture3.Picture

SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2

tims = 0
Timer1.Interval = 200
Timer1.Enabled = True
Form2.Picture = My_Picture(0)
MouseDown = False
hRgn = CreateEllipticRgn(0, 0, Form2.ScaleX(Form2.Width, vbTwips, vbPixels), Form2.ScaleY(Form2.Height, vbTwips, vbPixels))
SetWindowRgn Form2.hwnd, hRgn, True
Load Form1
Form1.Show
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseDown = True
TmpX = x
TmpY = y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If (MouseDown) Then
Form2.Move Form2.Left + (x - TmpX), Form2.Top + (y - TmpY)
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseDown = False

If Button = vbRightButton Then
MsgBox "Computer00 祝大家元宵节快乐!" & vbCrLf & "欢迎访问我的个人博客:http://computer00.21ic.org", vbOKOnly, "欢度新春"
End If

While (Form2.Top - 150 > 0 Or Form2.Left - Form2.Width + 100 < Screen.Width)
If Form2.Top - 150 > 0 Then Form2.Move Form2.Left, Form2.Top - 100
If Form2.Left + Form2.Width + 100 < Screen.Width Then Form2.Move Form2.Left + 80, Form2.Top
DoEvents
Sleep 10
Wend
End Sub

Private Sub Timer1_Timer()
Form2.Picture = My_Picture(Times)
Times = Times + 1
If Times = 4 Then Times = 0
End Sub

⌨️ 快捷键说明

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