How do you copy all or part of RTF-text from editorgadget to another editorgadget? Using getgadgettext() it only gets plain text.
Timo
Copy RTF text?
Re: Copy RTF text?
I dont know exactly but can you not use SendMessage_() ? Im sure there are #WM_COPY and #WM_PASTE to do it somehow...omit59 wrote:How do you copy all or part of RTF-text from editorgadget to another editorgadget? Using getgadgettext() it only gets plain text.
Timo
This works here, I'm not sure if this is what you're looking for:
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
El_Choni
That works very nice El_Choni, thank you!
However Iam still having trouble:
Iam using a callback to check if tab has been pressed or editorgadget has changed. The mask is:
This effects editorgadget so that it doesn't change RTF-text background color when using your copy snippet, however all other changes seem to work all right.
If the mask is removed copying works well.
Timo
However Iam still having trouble:
Iam using a callback to check if tab has been pressed or editorgadget has changed. The mask is:
Code: Select all
;...We catch the events in the #WM_COMMAND and #WM_NOTIFY msg in our CallBack procedure
SendMessage_(GadgetID(#MainEditor), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS|#ENM_CHANGE|SendMessage_(GadgetID(#MainEditor), #EM_GETEVENTMASK, 0, 0))
If the mask is removed copying works well.
Timo



