Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.interop
probleme with drag-n-drop windows shell extension
khelifaoui
10/30/2007 1:51:00 PM
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.GetCanonicalFormatEtc(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(uint 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/Forums.aspx/dotnet-intero...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
probleme with drag-n-drop windows shell extension
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password