HighTechTalks DotNet Forums  

probleme with drag-n-drop windows shell extension

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss probleme with drag-n-drop windows shell extension in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
khelifaoui via DotNetMonster.com
 
Posts: n/a

Default probleme with drag-n-drop windows shell extension - 10-30-2007 , 09:51 AM






HI ALL
I'v have implemented a NameSpace Extension in c# which suppports Drag
& Drop. I have implemented IOLEDropTarget Interface succesfully and I am able
to Drag from Explorer to my NSE without any problems. but the probleme is
when I Drag from NSE to Explorer please like th implimentation of my
IDataObject :

using System;
using System.Windows.Forms;
using WindowsShell.Interop;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;


namespace WindowsShell.Nspace
{
/// <summary>
/// Summary description for DataObjectImpl.
/// </summary>
internal class DataObjectImpl : WindowsShell.Interop.IDataObject
{
IFolderObject Root;


[DllImport("user32", EntryPoint = "RegisterClipboardFormat")]
public static extern uint RegisterClipboardFormatA(string lpString);
[DllImport("user32", EntryPoint = "GetClipboardFormatName")]
public static extern int GetClipboardFormatNameA(int wFormat, out
string lpString, int nMaxCount);


string CFSTR_PREFERREDDROPEFFECT = ("Preferred DropEffect");
string CFSTR_SHELLIDLIST = "Shell IDList Array"; // CF_IDLIST
string CFSTR_FILECONTENTS = "FileContents"; // CF_FILECONTENTS
string CFSTR_NSEDRAGDROP = "NSEDRAGDROP";
string CFSTR_FILEDESCRIPTOR = "FileGroupDescriptor";
// This is my custom FOrmat...
string CFSTR_CWEXTENSIONDATA = "CWExtensionFormat";


uint m_PreferredDropEffect;
uint m_ShellIdList;
uint m_CWExtensionData;
uint m_FileDescriptor;
uint m_FileContents;
int m_iCurrent = 0;
uint m_CFSTR_NSEDRAGDROP;

public int S_OK = unchecked((int)0x00000000L);
public int E_NOTIMPL = unchecked((int)0x80004001L);
public int E_INVALIDARG = unchecked((int)0x80070057L);
public int DV_E_DVASPECT = unchecked((int)0x8004006BL);
public int DV_E_TYMED = unchecked((int)0x80040069L);
public int DV_E_FORMATETC = unchecked((int)0x80040064L);
public int DV_E_LINDEX = unchecked((int)0x80040068L);

int m_itemCount = 0;
int m_cFormatsAvailable = 4;
FormatEtc[] m_fmtetc;


internal DataObjectImpl(IFolderObject rootObj, IntPtr[] apidl, int
ItemCount)
{
//file://populate/ the dataobject
Root = rootObj;

m_CWExtensionData = RegisterClipboardFormatA
(CFSTR_CWEXTENSIONDATA);
m_PreferredDropEffect = RegisterClipboardFormatA
(CFSTR_PREFERREDDROPEFFECT);
m_ShellIdList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
m_FileDescriptor = RegisterClipboardFormatA(CFSTR_FILEDESCRIPTOR)
;
m_FileContents = RegisterClipboardFormatA(CFSTR_FILECONTENTS);
m_CFSTR_NSEDRAGDROP = RegisterClipboardFormatA(CFSTR_NSEDRAGDROP)
;
m_itemCount = ItemCount;

m_fmtetc = new FormatEtc[m_cFormatsAvailable];

SetDefFormatEtc(ref m_fmtetc[0], m_CWExtensionData);
SetDefFormatEtc(ref m_fmtetc[1], m_ShellIdList);
SetDefFormatEtc(ref m_fmtetc[2], (uint)WindowsShell.Nspace.
Clipformat.CLIPFORMAT.CF_HDROP);
SetDefFormatEtc(ref m_fmtetc[3], m_PreferredDropEffect);

}

void SetDefFormatEtc(ref FormatEtc pFE, uint cfFormat)
{
// MessageBox.Show("SetDefFormatEtc");
pFE.cfFormat = (ushort)cfFormat;
pFE.dwAspect = DeviceAspects.Content;
pFE.tymed = StorageMedia.IStream;
pFE.lindex = -1;
pFE.ptd = (IntPtr)0;
}
void WindowsShell.Interop.IDataObject.GetData([In] ref FormatEtc
pformatetcIn, ref STGMEDIUM pmedium)
{
// MessageBox.Show("GetData");
if (pformatetcIn.cfFormat == m_CFSTR_NSEDRAGDROP)
{
MessageBox.Show("m_CFSTR_NSEDRAGDROP");
}
else if (pformatetcIn.cfFormat ==(ushort) WindowsShell.Nspace.
Clipformat.CLIPFORMAT.CF_HDROP) //drag from NSE to system NS
{
MessageBox.Show("CF_HDROP");
}
//return S_OK;
//MessageBox.Show(m_fmtetc[2].cfFormat.ToString());
throw new NotImplementedException();
}
void WindowsShell.Interop.IDataObject.GetDataHere(ref FormatEtc
pformatetc, ref System.Runtime.InteropServices.ComTypes.STGMEDIUM pmedium)
{

throw new NotImplementedException();
}
int WindowsShell.Interop.IDataObject.QueryGetData(ref FormatEtc
pformatetc)
{
if (pformatetc.cfFormat != m_CFSTR_NSEDRAGDROP &&
pformatetc.cfFormat != (ushort)WindowsShell.Nspace.Clipformat.
CLIPFORMAT.CF_HDROP)


return DV_E_FORMATETC;

if (pformatetc.ptd != null)
return E_INVALIDARG;
if ((pformatetc.dwAspect ) == 0)
return DV_E_DVASPECT;

if (pformatetc.lindex != -1)
return DV_E_LINDEX;

if ((pformatetc.tymed ) == 0)
return DV_E_TYMED;
// throw new NotImplementedException();
}
int WindowsShell.Interop.IDataObject.GetCanonicalForma tEtc(ref
FormatEtc pformatectIn, out FormatEtc pformatetcOut)
{
throw new NotImplementedException();
}
int WindowsShell.Interop.IDataObject.SetData(ref FormatEtc pformatetc,
ref System.Runtime.InteropServices.ComTypes.STGMEDIUM pmedium, bool fRelease)
{
throw new NotImplementedException();
}

int WindowsShell.Interop.IDataObject.EnumFormatEtc(uin t a, out
IEnumFormatEtc b)
{ //throw new NotSupportedException();
//return E_NOTIMPL;
switch (a)
{
case 1:
//int rajesh =
// SHCreateStdEnumFmtEtc((uint)m_cFormatsAvailable,
m_fmtetc, out b);//(new
//EnumFormatEtcImpl(m_fmtetc, m_cFormatsAvailable);

b = new EnumFormatEtcImpl(m_fmtetc, m_cFormatsAvailable);

break;
case 2:
default:
b = null;
break;
}
if (b == null)
{

return E_NOTIMPL;
}

return S_OK;
// throw new NotImplementedException();
}

int WindowsShell.Interop.IDataObject.DAdvise(ref FormatEtc pformatetc,
uint advf, WindowsShell.Interop.IAdviseSink pAdvSink, out uint pdwConnection)
{
throw new NotImplementedException();
}
int WindowsShell.Interop.IDataObject.DUnadvise(uint dwConnection)
{
throw new NotImplementedException();
}
int WindowsShell.Interop.IDataObject.EnumDAdvise(out IEnumStatData
ppenumAdvise)
{
throw new NotImplementedException();
}
//*******************************


}
}

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...terop/200710/1


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.