Picture1内装入图片后放入一个lable控件,需要在程序运行时可移动此控件,Picture1控件的scalemode值为:1-twip时很正常,但因为要处理图像必须要以像素为单位故将此值改为:3-pixel,改完后控件的移动就不正常了,到处乱跳的,请大家帮忙看看应如何改的。
==============代码==========================
Dim bMoving As Boolean, bSizing As Boolean
Dim xStart As Long, yStart As LongPrivate Sub lblShape_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    On Error Resume Next    If Button = vbLeftButton Then
        bMoving = True
        xStart = x: yStart = y
        lblShape.MousePointer = 5
    ElseIf Button = vbRightButton Then
        PopupMenu mnuEdit
    ElseIf Button = vbMiddleButton Then
        PopupMenu mnuImage
    End If
    
End SubPrivate Sub lblShape_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)    lbl1 = lblShape.Left & "-" & lblShape.Top
    
    Dim lft As Long, tp As Long
    If bMoving Then
        lft = lblShape.Left + x - xStart
        tp = lblShape.Top + y - yStart
        
        If lft <= 0 Then lft = 0
        If tp <= 0 Then tp = 0
        If lft > picImage.Width - lblShape.Width Then lft = picImage.Width - lblShape.Width
        If tp > picImage.Height - lblShape.Height Then tp = picImage.Height - lblShape.Height
        lblShape.Move lft, tp
    End If
    
End SubPrivate Sub lblShape_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    On Error Resume Next    bMoving = False
    lblShape.MousePointer = 0
    
End Sub