1.在vb中,我已经在picturebox控件的mousemove事件中跟踪了鼠标的位置。我现在想在它的mouseup中,当鼠标点下放开时,可以在点下的位置画一个动态的控件,最好是图形控件,现在的问题是画出来的控件画到了窗体中,画不到picturebox中,多多指教谢谢!
2.如果控件可以画到picturebox中后,如果画多个,以后在想获取控件的属性对它操作的时候如何获取?谢谢

解决方案 »

  1.   

           GetHndle command1.hwnd
           SetParent command1.hwnd, picturebox.hwnd'----------------- 公用函数模块 -------------------
    Public Function GetHndle(ByVal hwnd As Long)
      SetWindowLong hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Or WS_CHILD
    End Function
      

  2.   

    Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim tb As TextBox
        If Button = vbLeftButton Then
            Set tb = Me.Controls.Add("VB.TextBox", "Text" & Me.Controls.Count)
            Set tb.Container = Picture1 '<-关键'
            tb.Move X, Y
            tb.Visible = True
        End If
    End Sub