Click here to Skip to main content
15,925,661 members
Home / Discussions / COM
   

COM

 
GeneralRe: sending data to dialog Pin
GuimaSun23-Jun-05 10:02
GuimaSun23-Jun-05 10:02 
GeneralUsing FoxPro COM in Asp.Net Pin
BCKY17-Jun-05 13:41
BCKY17-Jun-05 13:41 
Generalget IE caret position (x,y) Pin
17-Jun-05 4:58
suss17-Jun-05 4:58 
GeneralAccess Violation in Release of COM+ object in Release Version Pin
ameysp16-Jun-05 20:01
ameysp16-Jun-05 20:01 
GeneralRe: Access Violation in Release of COM+ object in Release Version Pin
GuimaSun23-Jun-05 9:53
GuimaSun23-Jun-05 9:53 
GeneralRe: Access Violation in Release of COM+ object in Release Version Pin
ameysp23-Jun-05 23:27
ameysp23-Jun-05 23:27 
GeneralAdd RTP filter Pin
mausot16-Jun-05 0:43
mausot16-Jun-05 0:43 
GeneralHelp with IDropTarget Interface really needed Pin
Jim Parsells15-Jun-05 17:29
Jim Parsells15-Jun-05 17:29 
Hello,
I have a class that contains a Shell Folder and PIDL. The class instances live in the .Tag of TreeView and ListView items. When a Drag containing file/directory information (as in dragged from Windows Explorer) is over or drops on one of the TreeViewNodes, I want to respond using the IDropTarget Interface of the Folder represented by my class instance.
My problem is that I cannot get the IDropTarget Interface to work. I suspect that I have either mis-defined it or have omitted some vital step prior to using it.

Specifics:
<ComImportAttribute(), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), _
Guid("00000122-0000-0000-C000-000000000046")> _
Public Interface IDropTarget
<PreserveSig()> _
Function DragEnter( _
ByVal pDataObj As System.Windows.Forms.IDataObject, _
ByVal grfKeyState As Integer, _
ByVal pt As POINT, _
ByRef pdwEffect As System.Windows.Forms.DragDropEffects) _
As Integer

<PreserveSig()> _
Function DragOver( _
ByVal grfKeyState As Integer, _
ByRef pt As POINT, _
ByRef pdwEffect As System.Windows.Forms.DragDropEffects) _
As Integer

<PreserveSig()> _
Function DragLeave()

<PreserveSig()> _
Function DragDrop( _
ByVal pDataObj As System.Windows.Forms.IDataObject, _
ByVal grfKeyState As Integer, _
ByRef pt As POINT, _
ByRef pdwEffect As System.Windows.Forms.DragDropEffects) _
As Integer
End Interface
Note: I am only calling DragEnter so far in my code.

Where POINT is declared:

<StructLayout(LayoutKind.Sequential)> _
Public Structure POINT
Dim x As Integer
Dim y As Integer
End Structure

The part that seems to work:
... code that sets up relPidl ...
Dim apidl(0) as IntPtr
apidl(0) = relPidl
Dim Eff As Integer
Dim theInterface As IDropTarget
Dim HR As Integer
HR = Me.Parent.m_Folder.GetUIObjectOf(IntPtr.Zero, 1, apidl, ShellDll.IID_IDropTarget, Eff, theInterface)
If HR <> 0 Then
Marshal.ThrowExceptionForHR(HR)
End If
Note: m_Folder is the shell Folder interface of the Folder that contains the Folder of interest. Folder & PIDL code has been working for months, though this is the first time I've used GetUIObjectOf. In any event the returned item is a System_ComObject, just like I expect.

The part that doesn't work:
... e is a System.Windows.Forms.DragEventArgs with valid data..
for example the DragEventArgs generated by dragging from Windows Explorer ...
...The target is a normal Windows directory reporting .IsDropTarget among its attributes ...
Dim IDrop As IDropTarget = target.GetDropTargetOf()
If Not IsNothing(IDrop) Then
Dim scrpt As New ShellDll.POINT()
scrpt.x = e.X
scrpt.y = e.Y
Dim eff As DragDropEffects = e.AllowedEffect
Try
Dim res As Integer = IDrop.DragEnter(CType(e.Data, IDataObject), e.KeyState, scrpt, eff)
Catch ex As Exception
Debug.WriteLine(ex.ToString)
End Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(IDrop)
End If
Always throws a NullReference exception after reporting:
A first chance exception of type 'System.NullReferenceException' occurred in exptreelib.dll
Additional information: Object reference not set to an instance of an object.

I strongly suspect some kind of Marshalling problem on the return from IDropTarget, but I will believe any explanation that works.

Thanks

Jim Parsells
GeneralManipulate CWnd-derived object in ActiveX Control Pin
dhamilton15-Jun-05 12:15
dhamilton15-Jun-05 12:15 
GeneralRe: Manipulate CWnd-derived object in ActiveX Control Pin
dhamilton17-Jun-05 6:57
dhamilton17-Jun-05 6:57 
GeneralSharing Memory between two components with MapViewOfFile... Pin
metal_rob15-Jun-05 5:17
metal_rob15-Jun-05 5:17 
GeneralRe: Sharing Memory between two components with MapViewOfFile... Pin
GuimaSun23-Jun-05 9:45
GuimaSun23-Jun-05 9:45 
GeneralIPropertyBag who knows?! Pin
Member 115323814-Jun-05 22:29
Member 115323814-Jun-05 22:29 
GeneralRe: IPropertyBag who knows?! Pin
User 21559722-Jun-05 4:50
User 21559722-Jun-05 4:50 
GeneralIPropertyBag who knows?! Pin
Member 115323814-Jun-05 22:28
Member 115323814-Jun-05 22:28 
GeneralStrange ActiveX behaviour. Pin
Jan van den Baard13-Jun-05 8:09
professionalJan van den Baard13-Jun-05 8:09 
Generalactivexscripting Pin
dittygrail12-Jun-05 23:08
dittygrail12-Jun-05 23:08 
GeneralBSTR Pin
pardis11-Jun-05 20:20
pardis11-Jun-05 20:20 
GeneralRe: BSTR Pin
User 21559713-Jun-05 3:44
User 21559713-Jun-05 3:44 
GeneralRe: BSTR Pin
Lim Bio Liong13-Jun-05 23:44
Lim Bio Liong13-Jun-05 23:44 
GeneralRe: BSTR Pin
Get.Well14-Jun-05 1:57
Get.Well14-Jun-05 1:57 
GeneralLooking for Excel ver.9 type library (and how to make it work!) Pin
minette9-Jun-05 3:58
minette9-Jun-05 3:58 
GeneralCopy data to spread sheet component from excel file Pin
Member 20313358-Jun-05 22:34
Member 20313358-Jun-05 22:34 
GeneralCapturing ActiveX events Pin
Haroon8-Jun-05 19:51
Haroon8-Jun-05 19:51 
GeneralSending User Defined Types over COM Interface Pin
ChemmieBro8-Jun-05 4:53
ChemmieBro8-Jun-05 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.