module1.bas

来自「非常漂亮的VB控件」· BAS 代码 · 共 58 行

BAS
58
字号
Attribute VB_Name = "Module1"
Declare Function ReleaseCapture Lib "user32" () As Long

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


Public Maxed As Boolean
Private TmpWidht As Integer
Private TmpHeight As Integer
Private TmpTop As Integer
Private TmpLeft As Integer
Private TmpRc As Integer
Private TmpTr As Integer
Private TmpBr As Integer
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1

'
'''' 要求:必须为有句柄的对象(即 Object_Name ) !
'    比如:窗体(Form),图画框(PictureBox),按钮(CommandButton)、、、、等 !
'
Public Sub Drag_me(Object_Name As Object)
    If Not Maxed Then
    ReleaseCapture
    SendMessage Object_Name.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    End If
End Sub


Public Sub MaxFrm(Frm As Form, Rc As Control, Tr As Control, Br As Control)
If Not Maxed Then
    TmpTop = Frm.Top
    TmpLeft = Frm.Left
    Frm.Top = 0
    Frm.Left = 0
    TmpWidht = Frm.Width
    TmpHeight = Frm.Height
    Frm.Height = Screen.Height - 500
    Frm.Width = Screen.Width
    TmpRc = Rc.Left
    TmpTr = Tr.Left
    TmpBr = Br.Left
    Rc.Left = Frm.Width - Rc.Width
    Tr.Left = Frm.Width - Tr.Width
    Br.Left = Frm.Width - Br.Width
    Maxed = True
Else
    Frm.Left = TmpLeft
    Frm.Top = TmpTop
    Frm.Width = TmpWidht
    Frm.Height = TmpHeight
    Rc.Left = TmpRc
    Tr.Left = TmpTr
    Br.Left = TmpBr
    Maxed = False
End If
End Sub

⌨️ 快捷键说明

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