窗体分隔

'以下为一个类代码,使用时在窗体相应位置中调用即可

Option Explicit

    Private myForm As Form   '应用窗体

    Private picP As Object   '做为分隔条的控件

    Private objBox1 As Object '分隔条左边控件

    Private objBox2 As Object '分隔条右边控件

Private Sub Class_Terminate()

    Set  myForm = Nothing

    Set  picP = Nothing

    Set  objBox1 = Nothing

    Set  objBox2 = Nothing

End Sub

Public Sub myInit(inForm As Form, pic As Object, obj1 As Object, obj2 As Object)

On Error GoTo err1

    '初始化各控件位置

    Set myForm = inForm

    Set picP = pic

    Set objBox1 = obj1

    Set objBox2 = obj2

    picP.MousePointer = 9

    picP.Appearance = 0

    picP.BackColor = &H8000000F

    picP.BorderStyle = 0

    picP.Width = 50

    objBox1.Top = 0

    objBox1.Left = 0

    objBox1.Width = 3000

    objBox1.Height = myForm.Height

    picP.Top = 0

    picP.Left = objBox1.Width

    picP.Height = myForm.Height    objBox2.Top = 0

    objBox2.Left = objBox1.Width + picP.Width

    objBox2.Height = myForm.Height

    objBox2.Width = myForm.Width - objBox1.Width - picP.Width

    picP.ZOrder (0)

Exit Sub

err1:

End Sub

Public Sub myMouseMove(MouseButton As Integer, X As Single)

On Error GoTo err1

    'picP控件的mouseMove事件中调用

    If  MouseButton  =  1 Then

        picP.Move picP.Left + X

        picP.ZOrder (0)

    End If

Exit Sub

err1:

End Sub

Public Sub myMouseUp(MouseButton As Integer)

On Error GoTo err1

    'picP控件的mouseUp事件中调用

    If  MouseButton  =  1  Then

        objBox1.Left = 0

        If  picP.Left  <  1000  Then

            objBox1.Width = 1000

            picP.Left = 1000

        Else

            If  picP.Left  >  myForm.Width  Then

                objBox1.Width = myForm.Width - 1000

                picP.Left = objBox1.Width

            Else

                objBox1.Width = picP.Left

            End If

        End If

        objBox2.Left = objBox1.Width + picP.Width

        objBox2.Width = myForm.Width - objBox1.Width - picP.Width

End If

Exit Sub

err1:

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值