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

📄 form1.frm

📁 类似于QQ抽屉菜单的实例。界面可以自由美化
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "QQ抽屉菜单"
   ClientHeight    =   8130
   ClientLeft      =   60
   ClientTop       =   465
   ClientWidth     =   2850
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   8130
   ScaleWidth      =   2850
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Fre1 
      BackColor       =   &H00C0C0FF&
      BorderStyle     =   0  'None
      Height          =   7935
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2295
      Begin VB.Frame Fre2 
         BackColor       =   &H0000FF00&
         BorderStyle     =   0  'None
         Height          =   495
         Index           =   4
         Left            =   0
         TabIndex        =   10
         Top             =   6720
         Width           =   2295
         Begin VB.CommandButton Command2 
            Caption         =   "退出"
            Height          =   495
            Left            =   480
            TabIndex        =   11
            Top             =   360
            Width           =   1455
         End
      End
      Begin VB.Frame Fre2 
         BackColor       =   &H0000FF00&
         BorderStyle     =   0  'None
         Height          =   855
         Index           =   3
         Left            =   0
         TabIndex        =   9
         Top             =   5400
         Width           =   2295
         Begin VB.CommandButton Command3 
            Caption         =   "选项"
            Height          =   660
            Left            =   480
            TabIndex        =   12
            Top             =   120
            Width           =   1335
         End
      End
      Begin VB.Frame Fre2 
         BackColor       =   &H0000FF00&
         BorderStyle     =   0  'None
         Height          =   615
         Index           =   2
         Left            =   0
         TabIndex        =   8
         Top             =   4560
         Width           =   2295
         Begin VB.CommandButton Command4 
            Caption         =   "Command4"
            Height          =   375
            Left            =   600
            TabIndex        =   13
            Top             =   120
            Width           =   1335
         End
      End
      Begin VB.Frame Fre2 
         BackColor       =   &H0000FF00&
         BorderStyle     =   0  'None
         Height          =   495
         Index           =   1
         Left            =   0
         TabIndex        =   7
         Top             =   3720
         Width           =   2295
         Begin VB.CommandButton Command5 
            Caption         =   "Command5"
            Height          =   495
            Left            =   360
            TabIndex        =   14
            Top             =   240
            Width           =   1455
         End
      End
      Begin VB.Frame Fre2 
         BackColor       =   &H0000FF00&
         BorderStyle     =   0  'None
         Height          =   735
         Index           =   0
         Left            =   0
         TabIndex        =   6
         Top             =   2760
         Width           =   2295
         Begin VB.CommandButton Command6 
            Caption         =   "Command6"
            Height          =   495
            Left            =   480
            TabIndex        =   15
            Top             =   240
            Width           =   1575
         End
      End
      Begin VB.CommandButton c1 
         Caption         =   "退出系统"
         Height          =   495
         Index           =   4
         Left            =   0
         TabIndex        =   5
         Top             =   1920
         Width           =   2295
      End
      Begin VB.CommandButton c1 
         Caption         =   "系统设置"
         Height          =   495
         Index           =   3
         Left            =   0
         TabIndex        =   4
         Top             =   1440
         Width           =   2295
      End
      Begin VB.CommandButton c1 
         Caption         =   "查询"
         Height          =   495
         Index           =   2
         Left            =   0
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   960
         Width           =   2295
      End
      Begin VB.CommandButton c1 
         Caption         =   "第二个项目"
         Height          =   495
         Index           =   1
         Left            =   0
         TabIndex        =   2
         Top             =   480
         Width           =   2295
      End
      Begin VB.CommandButton c1 
         Caption         =   "第一个项目"
         Height          =   495
         Index           =   0
         Left            =   0
         TabIndex        =   1
         Top             =   0
         Width           =   2295
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, n As Integer
Public je As Integer '记忆菜单上次数值,实现数据传送
Private Sub c1_Click(Index As Integer)
'提交内容到函数执行,4为当前菜单(0-4),index是按钮数组名称
chmove 4, Index
End Sub
Public Sub chmove(s As Integer, i As Integer)

'菜单智能移动函数代码S代表菜单的总数,i代表当前移动的是数组名称
Dim j As Integer
Dim x, y, z, x1, y1 As Integer
x = s '将x,y,z,x1赋于菜单总数,x存放frame1的固定值
y = s 'y存放的是移动后的按钮的固定值
z = s 'Z没用上
x1 = s 'X1没用上
j = 0 'j计算按钮的宽度
Do While s > 0 ' 这里是通过重复计算来计算按钮所需移动的总高度
   If je > i Then
    Do While x > i
      Do While y >= x
      j = j + 495 '495是每个按钮的高度
      y = y - 1
      Loop
      c1(x).Top = Fre1.Height - j
      x = x - 1
    Loop
    Else
    '-----------------向上代码
     For x = 0 To i
       For y = 0 To x
       j = j + 495
       Next
       c1(x).Top = j - 495
       j = 0
     Next
    End If
  s = s - 1
        For y1 = 0 To x1
      If y1 = i Then
       Fre2(y1).Visible = True
       Fre2(y1).Top = c1(y1).Top + c1(y1).Height
       If y1 <> z Then
       Fre2(y1).Height = c1(y1 + 1).Top - Fre2(y1).Top
       Else
       Fre2(y1).Height = Fre1.Height - c1(y1).Top - c1(y1).Height
       End If
      Else
       Fre2(y1).Visible = False
      End If
    Next
Loop
je = i '这里是记忆上次移动的按钮数组编号
End Sub



Private Sub Form_Load()

je = 4
Dim fr As Integer
Fre1.BackColor = RGB(168, 217, 189) '定义主框架的背景色
For fr = 0 To 4
Fre2(fr).Visible = False  '设置内部框架
Fre2(fr).BackColor = RGB(106, 137, 188)
Next
Call c1_Click(0)
End Sub

⌨️ 快捷键说明

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