可以!但是richtextbox他不是容器控件,你自己用cmd.move去调整,注意还要至上问题。

解决方案 »

  1.   

    '仅供参考Option ExplicitPrivate Declare Function SetParent Lib "user32" _
       (ByVal hWndChild As Long, _
        ByVal hWndNewParent As Long) As Long
    Private Declare Function GetCaretPos Lib "user32" _
       (lpPoint As POINTAPI) As Long
       
    Private Type POINTAPI
            x As Long
            y As Long
    End TypePrivate Sub Form_Load()
        SetParent Command1.hWnd, RichTextBox1.hWnd
    End SubPrivate Sub RichTextBox1_SelChange()
        Dim pt As POINTAPI
        Call GetCaretPos(pt)
        Command1.Left = pt.x * Screen.TwipsPerPixelX + 30
        Command1.Top = pt.y * Screen.TwipsPerPixelY
    End SubPrivate Sub Command1_Click()
        MsgBox "OK"
    End Sub