Page 5 of 6
Posted: Tue Mar 20, 2007 6:52 pm
by macros
Thank you very much.
Here it works nearly perfekt

Posted: Tue Mar 20, 2007 6:55 pm
by srod
More testing seems to confirm that this is a 'stable' solution, but on the face of it, it appears that the memory being set aside for the OLE object being streamed is immediately deleted. However, there seems to be something in the IStorage interface which I now presume is making a copy of the data.
COM does my head in at the best of times!

Posted: Sat Jun 30, 2007 3:45 pm
by Nico
Some suggestions for modifications:
Code: Select all
Structure RichEditOle
*pIntf.IRicheditOle
Refcount.l
hwnd.l
EndStructure
Procedure.l RichEdit_SetInterface(hWnd)
Protected No_Com.l
ForEach RichComObject()
If RichComObject()\hwnd=hwnd
No_Com=1
Break
EndIf
Next
If No_Com=0
AddElement(RichComObject())
RichComObject()\pIntf = ?VTable
RichComObject()\hwnd=hwnd
SendMessage_(hWnd, #EM_SETOLECALLBACK, 0, RichComObject())
ProcedureReturn RichComObject()
EndIf
EndProcedure
Procedure.l RichEdit_QueryInterface(*pObject.RichEditOle, REFIID, *ppvObj.LONG)
Protected *pointeur.IRicheditOle
*pointeur=*pObject
If CompareMemory(REFIID, ?IID_IUnknown, 16)=1 Or CompareMemory(REFIID, ?IID_IRichEditOleCallback, 16)=1
Debug "QueryInterface"
*ppvObj\l = *pObject
*pointeur\AddRef()
ProcedureReturn #S_OK
Else
*ppvObject=0
ProcedureReturn #E_NOINTERFACE
EndIf
EndProcedure
IID_IRichEditOleCallback: ;" 0x00020D03, 0, 0, 0xC0,0,0,0,0,0,0,0x46"
Data.l $00020D03
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IUnknown: ;"{00000000-0000-0000-C000-000000000046}"
Data.l $00000000
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
Posted: Sun Jul 01, 2007 10:57 am
by srod
Hi Nico.
One question; what does it do?

Posted: Sun Jul 01, 2007 11:24 am
by Nico
Your procedure RichEdit_QueryInterface was not complete even if we can do without it, and I completed your procedure RichEdit_SetInterface to avoid several instance of RicheditOle for the same Gadget.
Posted: Sun Jul 01, 2007 11:53 am
by srod
Got it, thanks. COM isn't one of my strong points I'm afraid!
The following is what I have at the moment and includes some rich edit formatting commands which I've picked up along the way.
CODE REMOVED - see the first post for the updated code.
Posted: Sun Jul 01, 2007 12:06 pm
by Nico
If you want, you can include my last procedure to copy an image without using the clipboard.
Posted: Thu Nov 29, 2007 11:18 am
by srod
Update : 29th Nov 2007.
Have adjusted the CatchRTF() and LoadRTF() functions which now add a second optional parameter in which you specify the format of the stream/file being loaded; #SF_TEXT (default) or #SF_RTF.
See topic :
http://www.purebasic.fr/english/viewtop ... 733#220733
See the first post for the code.
Posted: Mon Jan 26, 2009 9:36 pm
by rsts
srod wrote:I can prevent the drop easily enough, - snip
My suspicion is that you will need to intercept the drop, open the file yourself and somehow stream the contents whilst converting to rtf format yourself!
I'll keep searching however.

I'm using an ole enabled editorgadget into which I would like to dropprivate. Since olenabling appears to interfer with PB's native dragDrop processing, I'm very interested in learning how I can "intercept the drop" as referenced above.
It appears to be possible via the RichEdit_QueryAcceptData, however I am getting two notifications for each drag and drop - one when the dragged item enters the editorgadget boundary and another when it is dropped.
Does anyone know what additional information is available which will allow me to determine which of those actions it may have been?
Or perhaps if there's a better method?
cheers
Posted: Mon Jan 26, 2009 10:01 pm
by srod
Seems to work okay here with private drags and OLE enabled editor gadgets!
Here's the code I just quickly tried :
Code: Select all
XIncludeFile "OLEedit.pbi"
OpenWindow(0,0,0,480,400,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ListIconGadget(0,20,20,200,300,"Gadget 0", 195, #PB_ListIcon_FullRowSelect)
EditorGadget(1,250,20,200,300)
RichEdit_SetInterface(GadgetID(1))
AddGadgetItem(0, -1, "c:\test.txt")
AddGadgetItem(0, -1, "Beryl")
AddGadgetItem(0, -1, "Charles")
AddGadgetItem(0, -1, "Daniel")
AddGadgetItem(0, -1, "Ernest")
EnableGadgetDrop(1,#PB_Drop_Private, #PB_Drag_Move, 1)
Repeat
ev = WaitWindowEvent()
Select ev
Case #PB_Event_GadgetDrop
If EventDropType() = #PB_Drop_Private
Debug "Private drop " + Str(EventDropPrivate())
EndIf
Case #PB_Event_Gadget
If EventType() = #PB_EventType_DragStart
DragPrivate(1, #PB_Drag_Move)
EndIf
EndSelect
Until ev = #PB_Event_CloseWindow
I pasted some images alongside the drags... no problem!
Posted: Mon Jan 26, 2009 10:29 pm
by srod
Bug fixed in the above code...

Posted: Mon Jan 26, 2009 10:35 pm
by rsts
srod wrote:Bug fixed in the above code...

You really had me going there for a while
cheers
Posted: Mon Jan 26, 2009 10:43 pm
by srod
I see how certain drag operations seem to be upset by using PB's drag & drop commands which is no surprise really considering that rich edit controls seem to enable OLE drag/drop by default anyhow.
Posted: Tue Jan 27, 2009 4:27 pm
by rsts
OK, yours works fine.
Mine, on the other hand, accepts items dragged from outside the window (srod's does not) but does not seem to trigger a drop event for those dragged from the listicongadget. It does, however receive events in the RichEdit_QueryAcceptData procedure. One for any 'entry' and one when it's dropped. No way I can tell to distinguish them though.
Show us code! Well, as far as I can tell, it's as srods, the editorgadget does have some characteristics set via sendmessage to recognize links, etc, but the enablegadgetdrop is per srods example. The program weighs in at 20,000+ lines, so showing code is somewhat problematic.
Just wondering if someone may have come across this before and be able to offer a suggestion/hint.
cheers
Posted: Tue Jan 27, 2009 4:51 pm
by srod
Check out the 'fReally' parameter of the RichEdit_QueryAcceptData() function. I think this should allow you to determine when the drop actually occurs.