Usuario
insertar objeto en richtextbox

Pregunta
-
Hola a todos del foro...
Lo que quiero es insertar objeto en richtextbox1
Encontre este code en el internet .
necesito ayuda urgente con este problema.
Private Declare Ansi Function OleUIInsertObject Lib "oledlg.dll" Alias "OleUIInsertObjectA" (ByRef inParam As OleUIInsertObjectType) As Integer
' This is used to get the ProgID from Class ID.
' Note that this API need us to pass LPOLESTR * from Visual Basic.
Private Declare Unicode Function ProgIDFromCLSID Lib "ole32.dll" (ByRef clsid As Guid, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByRef strAddess As String) As Integer
' Constants used in the dwFlags of OleUIInsertObjectType.Private Declare Function OleCreate Lib "ole32.dll" (<[In]()> ByRef rclsid As Guid, <[In]()> ByRef riid As Guid, ByVal renderopt As UInteger, <[In]()> ByRef pFormatEtc As Integer, ByVal pClientSite As Int32, ByVal pStg As Int32, _
<MarshalAs(UnmanagedType.IUnknown)> ByRef ppvObj As Object) As IntegerPrivate Declare Function OleRun Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByVal pUnknown As Object) As Integer
......
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential, pack:=1)> _
Private Structure OleUIInsertObjectType
......
End StructurePrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim UIInsertObj As OleUIInsertObjectType
Dim retValue As Integer
Dim lpolestr, ProgId As String
Dim myguid As Guid
Try
' Prepare the OleUIInsertObjectType.
UIInsertObj.cbStruct = Runtime.InteropServices.Marshal.SizeOf(GetType(OleUIInsertObjectType))
UIInsertObj.dwFlags = IOF_SELECTCREATENEW
UIInsertObj.hWndOwner = Me.Handle.ToInt32
UIInsertObj.lpszFile = New String(ControlChars.NullChar, 256)
UIInsertObj.cchFile = Len(UIInsertObj.lpszFile)' Call the API to display the dialog box.
retValue = OleUIInsertObject(UIInsertObj)
If retValue = OLEUI_OK Then
' If we select to insert from a new object
If (UIInsertObj.dwFlags And IOF_SELECTCREATENEW) = IOF_SELECTCREATENEW Then
ProgIDFromCLSID(UIInsertObj.clsid, lpolestr)
'MsgBox(lpolestr)OleCreate(UIInsertObj.clsid, UIInsertObj.IID, UIInsertObj.oleRender, UIInsertObj.lpFormatEtc, UIInsertObj.lpIOleClientSite, UIInsertObj.lpIStorage, UIInsertObj.ppvObj)
OleRun(Val(UIInsertObj.clsid.ToString))'RichTextBox1.OLEObjects.add(, , "", ProgId)
Else ' If we select to insert from file
'RichTextBox1.OLEObjects.add(, , UIInsertObj.lpszFile)
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End SubSi se modifica el code solo se logra abrir es cuadro de dialogo
CAPTURAS DE WORDPAD
Lo que quiero es insertar objeto desde este cuadro de dialogo en richtexbox1
decirles de antemano gracias
- Editado JenCarlos martes, 26 de mayo de 2015 16:30
- Cambiado Enrique M. Montejo viernes, 29 de mayo de 2015 6:33 Pregunta relacionada con controles de Windows Forms.
Todas las respuestas
-
Qué es lo que quieres conseguir en realidad, me refiero insertar objeto en richtexbox, porque a lo mejor te puedes quitar de usar código y hacer otra cosa más fácil.
Ps: No he visto el código.
Si la contestación te ha servido de ayuda márcala como respuesta. Si lo que publico no funciona, no tengo la culpa, SOY HUMANO, no una máquina.
-
Este trozo de code esta en vb 6 y no entiendo, veras yo estoy trabjango vb.net 2012
me arroja error
'RichTextBox1.OLEObjects.add(, , "", ProgId)
Else ' If we select to insert from file
'RichTextBox1.OLEObjects.add(, , UIInsertObj.lpszFile)
End Iflo que quiero es pegar el objeto o agregar en richtextbox1 desde el cuadro de dialogo mostrado anteriormente
-
Qué tipo de error es, puedes señalar la línea. Puedes poner la página de donde has obtenido esta información.
Si la contestación te ha servido de ayuda márcala como respuesta. Si lo que publico no funciona, no tengo la culpa, SOY HUMANO, no una máquina.
- Editado LTNs martes, 26 de mayo de 2015 18:19
-