A customer asks if drag/drop is available in a COM server.
Contrary to what some (wOOdy <g>) believe, I do not have all the answers. However, I can create some code to test it and I can look through the crystal ball of the Visual Studio debugger.
I found code that disables drag/drop if the Automation mode of the VFP runtime is not None. Because I wrote most of the COM server features of VFP, I thought that I had done it. Looking back through the source code logs, I see that it was done in early 1997 when OLE DragDrop was added and not by me!
Typically COM servers are software modules that are called to do tasks via clients, and do not have UI, so I don’t think it’s unreasonable that it was disabled in this scenario.
The Automation mode of VFP can be one of 5 values:
There are various places in the VFP source code that do different things depending on the automation mode. For example, an In Proc server does not create a real Windows window for a Form object. You can test that the hWnd of a Form is 0
(Create a general purpose VFP com server: http://blogs.msdn.com/calvin_hsia/archive/2004/06/18/159550.aspx)
x=CREATEOBJECT("t1.c1")
?x.MyEval("_vfp.ServerName")
?x.MyEval("_vfp.fullName")
?x.MyDoCmd("public ox")
?x.MyDoCmd("ox=CREATEOBJECT('form')")
?x.MyEval("ox.hwnd")
Try running the code below to see the difference in OLE Drag Drop
CLEAR
IF FILE("frmtest.exe")
?"Unreg"
!frmtest /unregserver
ENDIF
TEXT TO ctemp
*********** My COM EXE code *****************
DEFINE CLASS myform AS form OLEPUBLIC
Name = "myForm"
ShowWindow = 2
ADD OBJECT text1 AS textbox WITH ;
OLEDragMode = 1, ;
Height = 23, ;
Left = 36, ;
Top = 36, ;
Width = 100, ;
SelectOnEntry = .t., ;
Name = "Text1"
ADD OBJECT text2 AS textbox WITH ;
OLEDropMode = 1, ;
Top = 96, ;
Name = "Text2"
PROCEDURE Init
this.Show
this.text1.Value = "DragMe"
ENDPROC
ENDDEFINE
*********** End of code ***************
ENDTEXT
STRTOFILE(ctemp,"frmtest.prg")
BUILD PROJECT frmtest FROM frmtest
BUILD EXE frmtest FROM frmtest
PUBLIC oForm,oForm2
oForm = CREATEOBJECT("frmtest.myform")
oForm.Caption="COM Server"
oForm2 = NEWOBJECT("myform","frmtest.prg")
oForm2.caption="Non-Com server"
oForm2.top=300