Code: Select all
#RECO_COPY = 2
If OpenWindow(0, 200, 50, 640, 480, "Editor Gadget Copy Paste", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget)=0:End:EndIf
If CreateMenu(0, WindowID(0))=0:End:EndIf
MenuTitle("&Edit")
MenuItem(0, "Paste to 2")
If CreateGadgetList(WindowID(0))=0:End:EndIf
EditorGadget(0, 0, 0, WindowWidth(0)/2, WindowHeight(0))
EditorGadget(1, WindowWidth(0)/2, 0, WindowWidth(0)/2, WindowHeight(0))
Repeat
EventID = WaitWindowEvent()
If EventID=#PB_Event_Menu And EventMenu()=0
SendMessage_(GadgetID(0), #EM_GETOLEINTERFACE, 0, @Object.IRichEditOle)
chr.s = Space(8):PokeL(@chr, 0):PokeL(@chr+4, -1) ; Workaround for bug in IRichEditOle::GetClipboardData PB definition
; chr.CHARRANGE\cpMax = -1 ; end char (0, -1): the whole data
; Object\GetClipboardData(@chr, #RECO_COPY, @dataobj.IDataObject)
Object\GetClipboardData(chr, #RECO_COPY, @dataobj.IDataObject)
SendMessage_(GadgetID(1), #EM_GETOLEINTERFACE, 0, @Object2.IRichEditOle)
Object2\ImportDataObject(dataobj, 0, 0) ; text will replace current selection or
EndIf ; placed at currect cursor position
Until EventID=#PB_Event_CloseWindow
End

