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

📄 form2.frm

📁 XP风格浮动工具条 和苹果风格按钮控件
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   BorderStyle     =   0  'None
   Caption         =   "皮肤窗口示例"
   ClientHeight    =   3090
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4680
   Icon            =   "Form2.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin prjXPFrame.xpFrame skin 
      Height          =   2865
      Left            =   75
      TabIndex        =   0
      Top             =   255
      Width           =   4485
      _extentx        =   7911
      _extenty        =   5054
      headertextfont  =   "Form2.frx":038A
      footertextfont  =   "Form2.frx":03AE
      containertextfont=   "Form2.frx":03DA
      headertext      =   "MyNiceFrame1"
      footertext      =   ""
      headertext      =   "MyNiceFrame1"
      footertext      =   ""
      containerresizable=   -1  'True
      zorderonfocus   =   0   'False
      Begin prjXPFrame.isButton cmdClose 
         Height          =   360
         Left            =   3345
         TabIndex        =   1
         Top             =   765
         Width           =   390
         _extentx        =   688
         _extenty        =   635
         icon            =   "Form2.frx":0400
         style           =   7
         caption         =   " "
         iconalign       =   1
         inonthemestyle  =   0
         Object.tooltiptext     =   "关闭"
         tooltiptitle    =   ""
         tooltipicon     =   0
         tooltiptype     =   0
         ttforecolor     =   0
         font            =   "Form2.frx":079C
      End
      Begin prjXPFrame.isButton cmdMax 
         Height          =   360
         Left            =   3345
         TabIndex        =   2
         Top             =   1575
         Width           =   390
         _extentx        =   688
         _extenty        =   635
         icon            =   "Form2.frx":07C4
         style           =   7
         caption         =   " "
         iconalign       =   1
         inonthemestyle  =   0
         Object.tooltiptext     =   "最大化"
         tooltiptitle    =   ""
         tooltipicon     =   0
         tooltiptype     =   0
         ttforecolor     =   0
         font            =   "Form2.frx":0B60
      End
      Begin prjXPFrame.isButton cmdMin 
         Height          =   360
         Left            =   1710
         TabIndex        =   3
         Top             =   675
         Width           =   390
         _extentx        =   688
         _extenty        =   635
         icon            =   "Form2.frx":0B88
         style           =   7
         caption         =   " "
         iconalign       =   1
         inonthemestyle  =   0
         Object.tooltiptext     =   "最小化"
         tooltiptitle    =   ""
         tooltipicon     =   0
         tooltiptype     =   0
         ttforecolor     =   0
         font            =   "Form2.frx":0F24
      End
      Begin prjXPFrame.isButton cmdRestore 
         Height          =   360
         Left            =   2295
         TabIndex        =   4
         Top             =   1365
         Visible         =   0   'False
         Width           =   390
         _extentx        =   688
         _extenty        =   635
         icon            =   "Form2.frx":0F4C
         style           =   7
         caption         =   " "
         iconalign       =   1
         inonthemestyle  =   0
         Object.tooltiptext     =   ""
         tooltiptitle    =   ""
         tooltipicon     =   0
         tooltiptype     =   0
         ttforecolor     =   0
         font            =   "Form2.frx":12E8
      End
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
Private Declare Function ClientToScreen Lib "User32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Sub 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)
Dim oldW As Long, oldH As Long
Private OldX As Integer
Private OldY As Integer
Private DragMode As Boolean
Dim MoveMe As Boolean

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdMax_Click()
    oldW = Me.Width
    oldH = Me.Height
    Me.WindowState = vbMaximized
    cmdMax.visible = False: cmdRestore.visible = True
    skin.Left = 0: skin.Top = 0: skin.Width = Me.Width + 8: skin.Height = Me.Height + 8: skin.HeaderText = Me.Caption
    If skin.ContainerShapeStyle = Rounded Then SmoothForm Me, skin.ContainerCornerRadius
    cmdClose.Top = 0: cmdClose.Left = skin.Width - cmdClose.Width - 8
    cmdMax.Top = 0: cmdMax.Left = skin.Width - cmdMax.Width - cmdClose.Width - 8
    cmdRestore.Top = 0: cmdRestore.Left = skin.Width - cmdRestore.Width - cmdClose.Width - 8
    cmdMin.Top = 0: cmdMin.Left = skin.Width - cmdMin.Width - cmdRestore.Width - cmdClose.Width - 8
End Sub

Private Sub cmdMin_Click()
    Me.WindowState = vbMinimized
End Sub

Private Sub cmdRestore_Click()
    Me.WindowState = vbNormal
    skin.Width = oldW
    skin.Height = oldH
    Me.Width = oldW
    Me.Height = oldH
    cmdMax.visible = True: cmdRestore.visible = False
    Me.Width = skin.Width - 8: Me.Height = skin.Height - 8
    resizePaint
    Me.Refresh
    skin.Refresh
End Sub

Private Sub Form_Load()
    skin.Left = 0: skin.Top = 0: skin.Width = Me.Width + 8: skin.Height = Me.Height + 8: skin.HeaderText = Me.Caption
    If skin.ContainerShapeStyle = Rounded Then SmoothForm Me, skin.ContainerCornerRadius
    cmdClose.Top = 0: cmdClose.Left = skin.Width - cmdClose.Width - 8
    cmdMax.Top = 0: cmdMax.Left = skin.Width - cmdMax.Width - cmdClose.Width - 8
    cmdRestore.Top = 0: cmdRestore.Left = skin.Width - cmdRestore.Width - cmdClose.Width - 8
    cmdMin.Top = 0: cmdMin.Left = skin.Width - cmdMin.Width - cmdRestore.Width - cmdClose.Width - 8
End Sub

Private Sub skin_DblClick()
    If Me.WindowState = vbMaximized Then
        Call cmdRestore_Click
        Exit Sub
    End If
    If Me.WindowState = vbNormal Then
        Call cmdMax_Click
        MoveMe = False
        Exit Sub
    End If
End Sub

Private Sub skin_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.WindowState = vbMaximized Then Exit Sub
If Button = 2 Then Exit Sub
    MoveMe = True
    OldX = X
    OldY = Y
End Sub

Private Sub skin_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single, cResize As Boolean, cMove As Boolean)
If Me.WindowState = vbMaximized Then Exit Sub
If cResize = True Then Exit Sub
    If MoveMe = True Then
        Me.Left = Me.Left + (X - OldX)
        Me.Top = Me.Top + (Y - OldY)
    End If
End Sub

Private Sub skin_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.WindowState = vbMaximized Then Exit Sub
If Button = 2 Then Exit Sub
    Me.Left = Me.Left + (X - OldX)
    Me.Top = Me.Top + (Y - OldY)
    MoveMe = False
End Sub

Private Sub skin_Resize(cWidth As Long, cHeight As Long)
    Me.Width = skin.Width - 8: Me.Height = skin.Height - 8
    resizePaint
End Sub

Private Sub resizePaint()
    If skin.ContainerShapeStyle = Rounded Then SmoothForm Me, skin.ContainerCornerRadius
    cmdClose.Top = 0: cmdClose.Left = skin.Width - cmdClose.Width - 8
    cmdMax.Top = 0: cmdMax.Left = skin.Width - cmdMax.Width - cmdClose.Width - 8
    cmdRestore.Top = 0: cmdRestore.Left = skin.Width - cmdRestore.Width - cmdClose.Width - 8
    cmdMin.Top = 0: cmdMin.Left = skin.Width - cmdMin.Width - cmdRestore.Width - cmdClose.Width - 8
End Sub

⌨️ 快捷键说明

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