playyuer answer: 原文 http://microinfo.top263.net/Txt/EasyView.txt 例程下载 http://microinfo.top263.net/Zip/EasyView.exe例2:在 Delphi 提供了 Splitter 控件,轻而易举就实现了窗体界面的分割视图,而在 VB 中要实现这一 功能则要编写大量代码。 可参阅 VB 6 的"树状视图列表视图拆分条"控件集或"VB 应用程序向导 --> 资源管理器样式"代码, 现将其加工移植为 ActiveX Dll 部件: 创建ActiveX Dll(命名为:EasyViews)工程,并在类模块(命名为:SplitView) 添加如下代码:Option Explicit Dim mbMoving As BooleanConst iError = 120 Const iErrorXY = 150 Const SplitterHW = 80Dim LeftCtl As Control Dim RightCtl As Control Dim TopCtl As Control Dim BottomCtl As ControlDim WithEvents ImgSplitterH As Image Dim WithEvents ImgSplitterV As ImageDim PictureH As PictureBox Dim PictureV As PictureBoxDim WithEvents FormX As FormDim iMinWidth As Integer Dim iMinHeight As Integer Dim iLeftMargin As Integer Dim iRightMargin As Integer Dim iTopMargin As Integer Dim iBottomMargin As IntegerPublic Property Get LeftMargin() As Integer LeftMargin = iLeftMargin End PropertyPublic Property Let LeftMargin(ByVal vNewValue As Integer) iLeftMargin = vNewValue End PropertyPublic Property Get RightMargin() As Integer RightMargin = iRightMargin End PropertyPublic Property Let RightMargin(ByVal vNewValue As Integer) iRightMargin = vNewValue End PropertyPublic Property Get TopMargin() As Integer TopMargin = iTopMargin End PropertyPublic Property Let TopMargin(ByVal vNewValue As Integer) iTopMargin = vNewValue End PropertyPublic Property Get BottomMargin() As Integer BottomMargin = iBottomMargin End Property Public Property Let BottomMargin(ByVal vNewValue As Integer) iBottomMargin = vNewValue End PropertyPublic Property Get MinWidth() As Integer MinWidth = iMinWidth End PropertyPublic Property Let MinWidth(ByVal vNewValue As Integer) iMinWidth = vNewValue End PropertyPublic Property Get MinHeight() As Integer MinHeight = iMinHeight End PropertyPublic Property Let MinHeight(ByVal vNewValue As Integer) iMinHeight = vNewValue End PropertyPrivate Sub FormX_Load() Dim temp As Stringtemp = "DynamicImageH" On Error GoTo ErrorHandler FormX.Controls.Add "VB.Image", temp, FormX On Error GoTo 0 With FormX.Controls.Item(temp) .Visible = True End With Set ImgSplitterH = FormX.Controls.Item(temp) ImgSplitterH.MousePointer = 7 'ccsizeEWtemp = "DynamicImageV" On Error GoTo ErrorHandler FormX.Controls.Add "VB.Image", temp, FormX On Error GoTo 0 With FormX.Controls.Item(temp) .Visible = True End With Set ImgSplitterV = FormX.Controls.Item(temp) ImgSplitterV.MousePointer = 9 'cc2sizeNStemp = "DynamicPictureH" On Error GoTo ErrorHandler FormX.Controls.Add "VB.PictureBox", temp, FormX On Error GoTo 0 Set PictureH = FormX.Controls.Item(temp) PictureH.BorderStyle = 0 PictureH.BackColor = vbBlacktemp = "DynamicPictureV" On Error GoTo ErrorHandler FormX.Controls.Add "VB.PictureBox", temp, FormX On Error GoTo 0Set PictureV = FormX.Controls.Item(temp)PictureV.BorderStyle = 0 PictureV.BackColor = vbBlack LeftCtl.Move LeftMargin, TopMargin ImgSplitterV.Move LeftCtl.Left + LeftCtl.Width, LeftCtl.Top, SplitterHW, LeftCtl.Height RightCtl.Move ImgSplitterV.Left + SplitterHW, LeftCtl.Top RightCtl.Height = LeftCtl.Height ImgSplitterH.Move LeftCtl.Left, LeftCtl.Top + LeftCtl.Height, FormX.Width - LeftMargin - RightMargin, SplitterHW BottomCtl.Move LeftCtl.Left, LeftCtl.Top + LeftCtl.Height + SplitterHW 'LeftCtl.HeightExit Sub ErrorHandler: temp = temp & "X" Resume End SubPublic Sub Create(LeftCtlX As Object, RightCtlX As Object, BottomCtlX As Object) Set LeftCtl = LeftCtlX Set RightCtl = RightCtlX 'Set TopCtl = TopCtlX Set BottomCtl = BottomCtlX Set FormX = LeftCtlX.Container FormX_Load End SubPrivate Sub FormX_Resize() If FormX.WindowState <> vbMinimized Then If FormX.Width < LeftMargin + RightMargin + SplitterHW + MinWidth + LeftCtl.Width + iErrorXY Then FormX.Width = LeftMargin + RightMargin + SplitterHW + MinWidth + LeftCtl.Width + iErrorXY End If If FormX.Height < TopMargin + BottomMargin + SplitterHW + MinHeight + LeftCtl.Height + iErrorXY + iErrorXY + iErrorXY + 6 Then FormX.Height = TopMargin + BottomMargin + SplitterHW + MinHeight + LeftCtl.Height + iErrorXY + iErrorXY + iErrorXY + 6 End If RightCtl.Width = FormX.Width - LeftCtl.Width - SplitterHW - LeftMargin - RightMargin - iErrorXY ImgSplitterH.Width = FormX.Width - LeftMargin - RightMargin - iErrorXY BottomCtl.Width = ImgSplitterH.Width BottomCtl.Height = FormX.Height - ImgSplitterH.Top - BottomMargin - SplitterHW - 405 End If End SubPrivate Sub ImgSplitterH_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) With ImgSplitterH PictureH.Move .Left - 10, .Top, .Width + 30, .Height / 2 End With PictureH.Visible = True mbMoving = True End SubPrivate Sub ImgSplitterH_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then If mbMoving Then If Y + ImgSplitterH.Top < LeftCtl.Top + MinHeight Then PictureH.Top = LeftCtl.Top + MinHeight ElseIf Y + ImgSplitterH.Top > FormX.Height - BottomMargin - SplitterHW - MinHeight - iErrorXY - iErrorXY - iErrorXY Then PictureH.Top = FormX.Height - BottomMargin - SplitterHW - MinHeight - iErrorXY - iErrorXY - iErrorXY Else PictureH.Top = Y + ImgSplitterH.Top End If End If End If End SubPrivate Sub ImgSplitterH_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) LeftCtl.Height = PictureH.Top - LeftCtl.Top ImgSplitterV.Height = LeftCtl.Height RightCtl.Height = LeftCtl.Height ImgSplitterH.Top = PictureH.Top BottomCtl.Height = FormX.Height - ImgSplitterH.Top - BottomMargin - SplitterHW - 400 - 5 BottomCtl.Top = PictureH.Top + SplitterHW PictureH.Visible = False mbMoving = False End SubPrivate Sub ImgSplitterV_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) PictureV.Visible = True With ImgSplitterV PictureV.Move .Left, .Top - 10, .Width \ 2, .Height End With mbMoving = True End SubPrivate Sub ImgSplitterV_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then If mbMoving Then If X + ImgSplitterV.Left < LeftCtl.Left + MinWidth Then PictureV.Left = LeftCtl.Left + MinWidth ElseIf X + ImgSplitterV.Left > FormX.Width - SplitterHW - RightMargin - MinWidth - iErrorXY Then PictureV.Left = FormX.Width - SplitterHW - RightMargin - MinWidth - iErrorXY Else PictureV.Left = X + ImgSplitterV.Left End If End If PictureV.Height = LeftCtl.Height End If End SubPrivate Sub ImgSplitterV_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ImgSplitterV.Left = PictureV.Left LeftCtl.Width = PictureV.Left - LeftCtl.Left RightCtl.Width = FormX.Width - LeftCtl.Width - SplitterHW - LeftMargin - RightMargin - iErrorXY '- iError - 200 RightCtl.Left = PictureV.Left + SplitterHW PictureV.Visible = False mbMoving = False End Sub至此该部件创建完成。 接下来创建标准工程,并在窗体上绘制任意三个控件,如: TreeView、ListView、DataGrid,并编写 如下代码测试 EasyViews 部件的类 SplitView:Option Explicit Dim x As New EasyViews.SplitView Private Sub Form_Load() '... x.TopMargin = 500 ' Toolbar1.Height + 100 x.LeftMargin = 1000 x.RightMargin = 1000 x.BottomMargin = 500 'StatusBar1.Height x.MinHeight = 1000 x.MinWidth = 1200 x.Create TreeView1, ListView1, DataGrid1 '... End Sub
首先建立一个新工程,在窗体上面放置一个text、一个listbox和一个picturebox,分别命名为text1、listleft、Splitter。 代码如下: Option Explicit'variable to hold the width of the spltter bar Private Const SPLT_WDTH As Integer = 3'variable to hold the last-sized postion Private currSplitPosX As Long'variable to hold the horizontal and vertical offsets of the 2 controls Dim CTRL_OFFSET As Integer'variable to hold the Splitter bar colour Dim SPLT_COLOUR As Long Private Sub Form_Load() 'set the startup variablesCTRL_OFFSET = 5 SPLT_COLOUR = &H808080'set the current splitter bar position to an arbitrary value that will always be outside 'the possibe range. This allows us to check for movement of the spltter bar in subsequent 'mousexxx subs.currSplitPosX = &H7FFFFFFF 'note: VB3 users will need to substitute Chr$(13) & chr$(10) for the VB4 constant vbCrLf in the sentence below.'TextRight = "This code demonstrates how to implement a spliiter bar in a Visual Basic Project." & vbCrLf & vbCrLf & "It's actions are controlled through the MouseDown, MouseMove and MouseUp subs of the Splitter Picturebox, and the Resize event of the form."End Sub Private Sub Form_Resize()Dim x1 As Integer Dim x2 As Integer Dim height1 As Integer Dim width1 As Integer Dim width2 As IntegerOn Error Resume Next'set the height of the controlsheight1 = ScaleHeight - (CTRL_OFFSET * 2) x1 = CTRL_OFFSET width1 = ListLeft.Widthx2 = x1 + ListLeft.Width + SPLT_WDTH - 1 width2 = ScaleWidth - x2 - CTRL_OFFSET'move the left list ListLeft.Move x1% - 1, CTRL_OFFSET, width1, height1'move the right list TextRight.Move x2, CTRL_OFFSET, width2 + 1, height1'move the splitter bar Splitter.Move x1 + ListLeft.Width - 1, CTRL_OFFSET, SPLT_WDTH, height1End SubPrivate Sub Splitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = vbLeftButton Then 'change the splitter colour Splitter.BackColor = SPLT_COLOUR
'set the current position to x currSplitPosX = CLng(X) Else 'not the left button, so... if the current position <> default, cause a mouseup If currSplitPosX <> &H7FFFFFFF Then Splitter_MouseUp Button, Shift, X, Y
'set the current position to the default value currSplitPosX = &H7FFFFFFF End IfEnd Sub Private Sub Splitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'if the splitter has been moved... If currSplitPosX& <> &H7FFFFFFF Then'if the current position <> default, reposition the splitter and set this as the current value If CLng(X) <> currSplitPosX Then Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2) currSplitPosX = CLng(X)End IfEnd IfEnd Sub Private Sub Splitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)'if the splitter has been moved... If currSplitPosX <> &H7FFFFFFF Then 'if the current postition <> the last position do a final move of the splitter If CLng(X) <> currSplitPosX Then Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2) End If'call this the default position currSplitPosX = &H7FFFFFFF'restore the normal splitter colour Splitter.BackColor = &H8000000F'and check for valid sizings. 'Either enforce the default minimum & maximum widths for the left list, or, if within range, set the widthIf Splitter.Left > 60 And Splitter.Left < (ScaleWidth - 60) ThenListLeft.Width = Splitter.Left - ListLeft.Left 'the pane is within range ElseIf Splitter.Left < 60 Then 'the pane is too small ListLeft.Width = 60 Else ListLeft.Width = ScaleWidth - 60 'the pane is too wide End If 'reposition both lists, and the splitter bar Form_Resize End IfEnd Sub
原文 http://microinfo.top263.net/Txt/EasyView.txt
例程下载 http://microinfo.top263.net/Zip/EasyView.exe例2:在 Delphi 提供了 Splitter 控件,轻而易举就实现了窗体界面的分割视图,而在 VB 中要实现这一
功能则要编写大量代码。
可参阅 VB 6 的"树状视图列表视图拆分条"控件集或"VB 应用程序向导 --> 资源管理器样式"代码,
现将其加工移植为 ActiveX Dll 部件:
创建ActiveX Dll(命名为:EasyViews)工程,并在类模块(命名为:SplitView)
添加如下代码:Option Explicit
Dim mbMoving As BooleanConst iError = 120
Const iErrorXY = 150
Const SplitterHW = 80Dim LeftCtl As Control
Dim RightCtl As Control
Dim TopCtl As Control
Dim BottomCtl As ControlDim WithEvents ImgSplitterH As Image
Dim WithEvents ImgSplitterV As ImageDim PictureH As PictureBox
Dim PictureV As PictureBoxDim WithEvents FormX As FormDim iMinWidth As Integer
Dim iMinHeight As Integer
Dim iLeftMargin As Integer
Dim iRightMargin As Integer
Dim iTopMargin As Integer
Dim iBottomMargin As IntegerPublic Property Get LeftMargin() As Integer
LeftMargin = iLeftMargin
End PropertyPublic Property Let LeftMargin(ByVal vNewValue As Integer)
iLeftMargin = vNewValue
End PropertyPublic Property Get RightMargin() As Integer
RightMargin = iRightMargin
End PropertyPublic Property Let RightMargin(ByVal vNewValue As Integer)
iRightMargin = vNewValue
End PropertyPublic Property Get TopMargin() As Integer
TopMargin = iTopMargin
End PropertyPublic Property Let TopMargin(ByVal vNewValue As Integer)
iTopMargin = vNewValue
End PropertyPublic Property Get BottomMargin() As Integer
BottomMargin = iBottomMargin
End Property
Public Property Let BottomMargin(ByVal vNewValue As Integer)
iBottomMargin = vNewValue
End PropertyPublic Property Get MinWidth() As Integer
MinWidth = iMinWidth
End PropertyPublic Property Let MinWidth(ByVal vNewValue As Integer)
iMinWidth = vNewValue
End PropertyPublic Property Get MinHeight() As Integer
MinHeight = iMinHeight
End PropertyPublic Property Let MinHeight(ByVal vNewValue As Integer)
iMinHeight = vNewValue
End PropertyPrivate Sub FormX_Load()
Dim temp As Stringtemp = "DynamicImageH"
On Error GoTo ErrorHandler
FormX.Controls.Add "VB.Image", temp, FormX
On Error GoTo 0
With FormX.Controls.Item(temp)
.Visible = True
End With
Set ImgSplitterH = FormX.Controls.Item(temp)
ImgSplitterH.MousePointer = 7 'ccsizeEWtemp = "DynamicImageV"
On Error GoTo ErrorHandler
FormX.Controls.Add "VB.Image", temp, FormX
On Error GoTo 0
With FormX.Controls.Item(temp)
.Visible = True
End With
Set ImgSplitterV = FormX.Controls.Item(temp)
ImgSplitterV.MousePointer = 9 'cc2sizeNStemp = "DynamicPictureH"
On Error GoTo ErrorHandler
FormX.Controls.Add "VB.PictureBox", temp, FormX
On Error GoTo 0
Set PictureH = FormX.Controls.Item(temp)
PictureH.BorderStyle = 0
PictureH.BackColor = vbBlacktemp = "DynamicPictureV"
On Error GoTo ErrorHandler
FormX.Controls.Add "VB.PictureBox", temp, FormX
On Error GoTo 0Set PictureV = FormX.Controls.Item(temp)PictureV.BorderStyle = 0
PictureV.BackColor = vbBlack
LeftCtl.Move LeftMargin, TopMargin
ImgSplitterV.Move LeftCtl.Left + LeftCtl.Width, LeftCtl.Top, SplitterHW, LeftCtl.Height
RightCtl.Move ImgSplitterV.Left + SplitterHW, LeftCtl.Top
RightCtl.Height = LeftCtl.Height
ImgSplitterH.Move LeftCtl.Left, LeftCtl.Top + LeftCtl.Height, FormX.Width - LeftMargin - RightMargin, SplitterHW
BottomCtl.Move LeftCtl.Left, LeftCtl.Top + LeftCtl.Height + SplitterHW 'LeftCtl.HeightExit Sub
ErrorHandler:
temp = temp & "X"
Resume
End SubPublic Sub Create(LeftCtlX As Object, RightCtlX As Object, BottomCtlX As Object)
Set LeftCtl = LeftCtlX
Set RightCtl = RightCtlX
'Set TopCtl = TopCtlX
Set BottomCtl = BottomCtlX
Set FormX = LeftCtlX.Container
FormX_Load
End SubPrivate Sub FormX_Resize()
If FormX.WindowState <> vbMinimized Then
If FormX.Width < LeftMargin + RightMargin + SplitterHW + MinWidth + LeftCtl.Width + iErrorXY Then
FormX.Width = LeftMargin + RightMargin + SplitterHW + MinWidth + LeftCtl.Width + iErrorXY
End If
If FormX.Height < TopMargin + BottomMargin + SplitterHW + MinHeight + LeftCtl.Height + iErrorXY + iErrorXY + iErrorXY + 6 Then
FormX.Height = TopMargin + BottomMargin + SplitterHW + MinHeight + LeftCtl.Height + iErrorXY + iErrorXY + iErrorXY + 6
End If
RightCtl.Width = FormX.Width - LeftCtl.Width - SplitterHW - LeftMargin - RightMargin - iErrorXY
ImgSplitterH.Width = FormX.Width - LeftMargin - RightMargin - iErrorXY
BottomCtl.Width = ImgSplitterH.Width
BottomCtl.Height = FormX.Height - ImgSplitterH.Top - BottomMargin - SplitterHW - 405
End If
End SubPrivate Sub ImgSplitterH_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With ImgSplitterH
PictureH.Move .Left - 10, .Top, .Width + 30, .Height / 2
End With
PictureH.Visible = True
mbMoving = True
End SubPrivate Sub ImgSplitterH_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If mbMoving Then
If Y + ImgSplitterH.Top < LeftCtl.Top + MinHeight Then
PictureH.Top = LeftCtl.Top + MinHeight
ElseIf Y + ImgSplitterH.Top > FormX.Height - BottomMargin - SplitterHW - MinHeight - iErrorXY - iErrorXY - iErrorXY Then
PictureH.Top = FormX.Height - BottomMargin - SplitterHW - MinHeight - iErrorXY - iErrorXY - iErrorXY
Else
PictureH.Top = Y + ImgSplitterH.Top
End If
End If
End If
End SubPrivate Sub ImgSplitterH_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
LeftCtl.Height = PictureH.Top - LeftCtl.Top
ImgSplitterV.Height = LeftCtl.Height
RightCtl.Height = LeftCtl.Height
ImgSplitterH.Top = PictureH.Top
BottomCtl.Height = FormX.Height - ImgSplitterH.Top - BottomMargin - SplitterHW - 400 - 5
BottomCtl.Top = PictureH.Top + SplitterHW
PictureH.Visible = False
mbMoving = False
End SubPrivate Sub ImgSplitterV_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
PictureV.Visible = True
With ImgSplitterV
PictureV.Move .Left, .Top - 10, .Width \ 2, .Height
End With
mbMoving = True
End SubPrivate Sub ImgSplitterV_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If mbMoving Then
If X + ImgSplitterV.Left < LeftCtl.Left + MinWidth Then
PictureV.Left = LeftCtl.Left + MinWidth
ElseIf X + ImgSplitterV.Left > FormX.Width - SplitterHW - RightMargin - MinWidth - iErrorXY Then
PictureV.Left = FormX.Width - SplitterHW - RightMargin - MinWidth - iErrorXY
Else
PictureV.Left = X + ImgSplitterV.Left
End If
End If
PictureV.Height = LeftCtl.Height
End If
End SubPrivate Sub ImgSplitterV_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ImgSplitterV.Left = PictureV.Left
LeftCtl.Width = PictureV.Left - LeftCtl.Left
RightCtl.Width = FormX.Width - LeftCtl.Width - SplitterHW - LeftMargin - RightMargin - iErrorXY '- iError - 200
RightCtl.Left = PictureV.Left + SplitterHW
PictureV.Visible = False
mbMoving = False
End Sub至此该部件创建完成。
接下来创建标准工程,并在窗体上绘制任意三个控件,如: TreeView、ListView、DataGrid,并编写
如下代码测试 EasyViews 部件的类 SplitView:Option Explicit
Dim x As New EasyViews.SplitView
Private Sub Form_Load()
'...
x.TopMargin = 500 ' Toolbar1.Height + 100
x.LeftMargin = 1000
x.RightMargin = 1000
x.BottomMargin = 500 'StatusBar1.Height
x.MinHeight = 1000
x.MinWidth = 1200
x.Create TreeView1, ListView1, DataGrid1
'...
End Sub
例程下载 http://simideal.top263.net/Zip/EasyView.exe
代码如下:
Option Explicit'variable to hold the width of the spltter bar
Private Const SPLT_WDTH As Integer = 3'variable to hold the last-sized postion
Private currSplitPosX As Long'variable to hold the horizontal and vertical offsets of the 2 controls
Dim CTRL_OFFSET As Integer'variable to hold the Splitter bar colour
Dim SPLT_COLOUR As Long
Private Sub Form_Load()
'set the startup variablesCTRL_OFFSET = 5
SPLT_COLOUR = &H808080'set the current splitter bar position to an arbitrary value that will always be outside
'the possibe range. This allows us to check for movement of the spltter bar in subsequent
'mousexxx subs.currSplitPosX = &H7FFFFFFF
'note: VB3 users will need to substitute Chr$(13) & chr$(10) for the VB4 constant vbCrLf in the sentence below.'TextRight = "This code demonstrates how to implement a spliiter bar in a Visual Basic Project." & vbCrLf & vbCrLf & "It's actions are controlled through the MouseDown, MouseMove and MouseUp subs of the Splitter Picturebox, and the Resize event of the form."End Sub
Private Sub Form_Resize()Dim x1 As Integer
Dim x2 As Integer
Dim height1 As Integer
Dim width1 As Integer
Dim width2 As IntegerOn Error Resume Next'set the height of the controlsheight1 = ScaleHeight - (CTRL_OFFSET * 2)
x1 = CTRL_OFFSET
width1 = ListLeft.Widthx2 = x1 + ListLeft.Width + SPLT_WDTH - 1
width2 = ScaleWidth - x2 - CTRL_OFFSET'move the left list
ListLeft.Move x1% - 1, CTRL_OFFSET, width1, height1'move the right list
TextRight.Move x2, CTRL_OFFSET, width2 + 1, height1'move the splitter bar
Splitter.Move x1 + ListLeft.Width - 1, CTRL_OFFSET, SPLT_WDTH, height1End SubPrivate Sub Splitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = vbLeftButton Then
'change the splitter colour
Splitter.BackColor = SPLT_COLOUR
'set the current position to x
currSplitPosX = CLng(X)
Else
'not the left button, so... if the current position <> default, cause a mouseup
If currSplitPosX <> &H7FFFFFFF Then Splitter_MouseUp Button, Shift, X, Y
'set the current position to the default value
currSplitPosX = &H7FFFFFFF
End IfEnd Sub
Private Sub Splitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'if the splitter has been moved...
If currSplitPosX& <> &H7FFFFFFF Then'if the current position <> default, reposition the splitter and set this as the current value
If CLng(X) <> currSplitPosX Then
Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2)
currSplitPosX = CLng(X)End IfEnd IfEnd Sub
Private Sub Splitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)'if the splitter has been moved...
If currSplitPosX <> &H7FFFFFFF Then
'if the current postition <> the last position do a final move of the splitter
If CLng(X) <> currSplitPosX Then
Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2)
End If'call this the default position
currSplitPosX = &H7FFFFFFF'restore the normal splitter colour
Splitter.BackColor = &H8000000F'and check for valid sizings.
'Either enforce the default minimum & maximum widths for the left list, or, if within range, set the widthIf Splitter.Left > 60 And Splitter.Left < (ScaleWidth - 60) ThenListLeft.Width = Splitter.Left - ListLeft.Left 'the pane is within range
ElseIf Splitter.Left < 60 Then 'the pane is too small
ListLeft.Width = 60
Else
ListLeft.Width = ScaleWidth - 60 'the pane is too wide
End If
'reposition both lists, and the splitter bar
Form_Resize
End IfEnd Sub