一个简单的可调整分割条效果示例

Option Explicit   
  
Private Const AsyncMove As Boolean = False      '实时移动控制   
  
Dim mY As Long, AllHei As Long  
  
Private Sub Form_Load()   
    AllHei = Picture2.Top + Picture2.Height         '把大小极限先记录一下   
End Sub  
  
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)   
    mY = Y          '鼠标按下时的鼠标坐标   
End Sub  
  
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)   
    If Button And vbLeftButton Then  
        Dim tmpTop As Long  
           
        With Label1   
            tmpTop = .Top + Y - mY      '计算应该移动到的坐标   
               
            If tmpTop <= Picture1.Top Then tmpTop = Picture1.Top        '数值合法化   
            If tmpTop >= AllHei - .Height Then tmpTop = AllHei - .Height   
               
            .Move .Left, tmpTop             '先移动"分割条"   
               
            If AsyncMove = False Then  
                Picture1.Height = .Top - Picture1.Top       '再移动各控件   
                Picture2.Top = .Top + .Height   
                Picture2.Height = AllHei - Picture2.Top   
            End If  
        End With  
    End If  
End Sub  
  
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)   
    If AsyncMove = True Then  
        With Label1   
            Picture1.Height = .Top - Picture1.Top       '再移动各控件   
            Picture2.Top = .Top + .Height   
            Picture2.Height = AllHei - Picture2.Top   
        End With  
    End If  
End Sub  


下载文件 点击下载此文件

引用http://www.m5home.com/blog/article.asp?id=88
感谢老马



文章来自: 本站原创
引用通告地址: http://www.is21.cn/trackback.asp?tbID=355
Tags:
评论: 0 | 引用: 0 | 查看次数: 3035
发表评论
你没有权限发表留言!