要求:
拖动的时候应以虚线形式拖动,而不直接改变PictureBox的大小。(拖好了再变) 就像VB的工具栏一样。
  
分不够再加

解决方案 »

  1.   

    不能用 picturebox 实现
    你可以改用   activebar 2.x 控件
      

  2.   

    由于 picturebox 在 mdi 中只能在 top  bottom  left  right 不能 任意放置
      

  3.   

    我只要像VB工具栏一样就可以了
    把picturebox 方放在最左边。问题是:怎么拖动改变大小。
    不喜欢用多余的控件
      

  4.   

    触发DRAG事件
    对应鼠标坐标
      

  5.   

    这是我以前做的程序,你改改吧,加一个Image控件
    '用户拖动开始
    Private Sub imgSeperator_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            With imgSeperator
                picSeperator.Move .Left, .Top, .Width, .Height
            End With
            picSeperator.Visible = True
            picSeperator.Tag = "HasDraged" '表示以经有过拖动操作了
        End IfEnd Sub
    '用户拖动中
    Private Sub imgSeperator_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim sglPos As Single
        If Button = 1 Then
            sglPos = Y + imgSeperator.Top
            If sglPos < picHead.Height + M_PAIBAN_MIN_HEIGHT Then
                picSeperator.Top = picHead.Height + M_PAIBAN_MIN_HEIGHT
            ElseIf sglPos > picButton.Top - M_IMGSEPERATOR_HEIGHT Then
                picSeperator.Top = picButton.Top - M_IMGSEPERATOR_HEIGHT
            Else
                picSeperator.Top = sglPos
            End If
        End IfEnd Sub
    '用户拖动结束
    Private Sub imgSeperator_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        picSeperator.Visible = False
        imgSeperator.Top = picSeperator.Top '恢复拖动柄
        '按用户的要求对控件进行重排
        picCurPaiban.Height = picSeperator.Top - picCurPaiban.Top
        Dim intPicPreHeight As Long
        intPicPreHeight = picButton.Top - picSeperator.Top - picSeperator.Height
        picPrePaiban.Move 0, picSeperator.Top + picSeperator.Height, picMain.Width, _
                    IIf(intPicPreHeight < 0, 0, intPicPreHeight)
        
    End Sub
      

  6.   

    加入的image控件放一个图片,就是一个虚线那样的就行了,拖动的时候就是拖动image控件,等放开鼠标再把picture移动过去
      

  7.   

    但是IMAGE控件不能直接放进MDI窗体呀
      

  8.   

    呵呵
    错了,在mdi窗体里面我是改变鼠标的形状
    不是用image
      

  9.   

    不是在mdi窗体我才用上面的办法
      

  10.   

    刚开始没用虚线的效果,后来就改用activebar了
      

  11.   

    当然不是.虚线效果可以用DrawFocusRect
      

  12.   

    用spliterBar,免费的!跟vb工具栏一样.
      

  13.   

    picture1里面放一个picture2Dim xxPrivate Sub MDIForm_Load()
    With Picture2
       .Appearance = 0
       .BorderStyle = 0
       .BackColor = &H8000000F
       .DragMode = 1
       .MousePointer = 9
       .Top = -10000
       .Height = 100000
       .Width = 50
       .Left = Picture1.Width - 100
    End With
    End SubPrivate Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
    Picture1.Width = xx
    Picture2.Left = Picture1.Width - 100
    End SubPrivate Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    xx = X
    End Sub
    Private Sub MDIForm_DragDrop(Source As Control, X As Single, Y As Single)
    Picture1.Width = xx
    Picture2.Left = Picture1.Width - 100
    End SubPrivate Sub MDIForm_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    xx = X
    End Sub