本文整理汇总了C#中STGMEDIUM类的典型用法代码示例。如果您正苦于以下问题:C# STGMEDIUM类的具体用法?C# STGMEDIUM怎么用?C# STGMEDIUM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
STGMEDIUM类属于命名空间,在下文中一共展示了STGMEDIUM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetData
internal uint SetData(FORMATETC pformatetc, STGMEDIUM pmedium, bool release) {
return E_NOTIMPL;
}
示例2: STGMEDIUM
void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m) {
STGMEDIUM retMedium = new STGMEDIUM();
if (fmt == null || fmt.Length < 1)
return;
foreach (DataCacheEntry e in this.entries) {
if (e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/) {
retMedium.tymed = e.Format.tymed;
// Caller must delete the memory.
retMedium.unionmember = DragDropHelper.CopyHGlobal(new IntPtr(e.Data));
break;
}
}
if (m != null && m.Length > 0)
m[0] = retMedium;
}
示例3:
void IDataObject.SetData(FORMATETC[] fmt, STGMEDIUM[] m, int fRelease) {
}
示例4:
int IVsSimpleObjectList2.GetClipboardFormat(uint index, uint grfFlags, FORMATETC[] pFormatetc, STGMEDIUM[] pMedium)
{
return VSConstants.E_NOTIMPL;
}
示例5: STGMEDIUM
void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m)
{
STGMEDIUM retMedium = new STGMEDIUM();
if(fmt == null || fmt.Length < 1)
return;
SafeGlobalAllocHandle copy = null;
foreach(DataCacheEntry e in this.entries)
{
if(e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/)
{
retMedium.tymed = e.Format.tymed;
// Caller must delete the memory.
copy = DragDropHelper.CopyHGlobal(e.Data);
retMedium.unionmember = copy.DangerousGetHandle();
break;
}
}
if (m != null && m.Length > 0)
{
m[0] = retMedium;
if (copy != null)
copy.SetHandleAsInvalid();
}
}
示例6: CopyStgMedium
private static extern int CopyStgMedium(ref STGMEDIUM pcstgmedSrc, ref STGMEDIUM pstgmedDest);
示例7: CopyMedium
/// <summary>
/// Creates a copy of the STGMEDIUM structure.
/// </summary>
/// <param name="medium">The data to copy.</param>
/// <returns>The copied data.</returns>
private STGMEDIUM CopyMedium(ref STGMEDIUM medium)
{
STGMEDIUM sm = new STGMEDIUM();
int hr = CopyStgMedium(ref medium, ref sm);
if (hr != 0)
throw Marshal.GetExceptionForHR(hr);
return sm;
}
示例8: GetClipboardFormat
/// <summary>
/// Asks the given list item to renders a specific clipboard format that it supports.
/// </summary>
/// <param name="index"></param>
/// <param name="grfFlags"></param>
/// <param name="pFormatetc"></param>
/// <param name="pMedium"></param>
/// <returns></returns>
public int GetClipboardFormat(uint index, uint grfFlags, FORMATETC[] pFormatetc, STGMEDIUM[] pMedium)
{
return VSConstants.E_NOTIMPL;
}
示例9: STGMEDIUM
void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m) {
STGMEDIUM retMedium = new STGMEDIUM();
foreach (DataCacheEntry e in this.entries) {
if (e.format.cfFormat == fmt[0].cfFormat) {
retMedium.tymed = e.format.tymed;
retMedium.unionmember = CopyHGlobal(e.data);
break;
}
}
m[0] = retMedium;
}
示例10: GetDataHere
public uint GetDataHere(ref FORMATETC pFormatetc, out STGMEDIUM pMedium)
{
Trace.WriteLine("GetDataHere");
pMedium = new STGMEDIUM();
return (uint)E_NOTIMPL;
}
示例11: SetData
public uint SetData(ref FORMATETC a, ref STGMEDIUM b, bool fRelease)
{
//mpFormatetc = pFormatectIn;
//mpmedium = pmedium;
Trace.WriteLine("SetData");
return (int)S_OK;
}
示例12: GetData
public uint GetData(ref FORMATETC pFormatetc, ref STGMEDIUM pMedium)
{
IntPtr hDst = mBitmap.GetHbitmap();
pMedium.tymed = (int)TYMED.TYMED_GDI;
pMedium.unionmember = hDst;
pMedium.pUnkForRelease = IntPtr.Zero;
return (uint)S_OK;
}
示例13: STGMEDIUM
void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m)
{
STGMEDIUM retMedium = new STGMEDIUM();
if (fmt == null || fmt.Length < 1)
return;
foreach (DataCacheEntry e in this.entries)
{
if (e.format.cfFormat == fmt[0].cfFormat)
{
retMedium.tymed = e.format.tymed;
retMedium.unionmember = CopyHGlobal(new IntPtr(e.data));
break;
}
}
if (m != null && m.Length > 0)
m[0] = retMedium;
}
示例14: AddFormatAndMedium
private static bool AddFormatAndMedium(ClipboardFormats cfFormat, object data) {
STGMEDIUM medium;
FORMATETC format;
IntPtr hmem;
IntPtr hmem_ptr;
byte[] b;
switch(cfFormat) {
case ClipboardFormats.CF_TEXT: {
b = XplatUIWin32.StringToAnsi ((string)data);
hmem = XplatUIWin32.CopyToMoveableMemory (b);
break;
}
case ClipboardFormats.CF_UNICODETEXT: {
b = XplatUIWin32.StringToUnicode ((string)data);
hmem = XplatUIWin32.CopyToMoveableMemory (b);
break;
}
case ClipboardFormats.CF_HDROP: {
IEnumerator e;
StringBuilder sb;
long hmem_string_ptr;
IntPtr string_buffer;
int string_buffer_size;
sb = new StringBuilder();
// Make sure object is enumerable; otherwise
if ((data is string) || !(data is IEnumerable)) {
sb.Append(data.ToString());
sb.Append('\0');
sb.Append('\0');
} else {
e = ((IEnumerable)data).GetEnumerator();
while (e.MoveNext()) {
sb.Append(e.Current.ToString());
sb.Append('\0');
}
sb.Append('\0');
}
string_buffer = Marshal.StringToHGlobalUni(sb.ToString());
string_buffer_size = (int)XplatUIWin32.Win32GlobalSize(string_buffer);
// Write DROPFILES structure
hmem = XplatUIWin32.Win32GlobalAlloc(XplatUIWin32.GAllocFlags.GMEM_MOVEABLE | XplatUIWin32.GAllocFlags.GMEM_DDESHARE, 0x14 + string_buffer_size);
hmem_ptr = XplatUIWin32.Win32GlobalLock(hmem);
Marshal.WriteInt32(hmem_ptr, 0x14); // pFiles
Marshal.WriteInt32(hmem_ptr, 1 * Marshal.SizeOf(typeof(uint)), 0); // point.x
Marshal.WriteInt32(hmem_ptr, 2 * Marshal.SizeOf(typeof(uint)), 0); // point.y
Marshal.WriteInt32(hmem_ptr, 3 * Marshal.SizeOf(typeof(uint)), 0); // fNc
Marshal.WriteInt32(hmem_ptr, 4 * Marshal.SizeOf(typeof(uint)), 1); // fWide
hmem_string_ptr = (long)hmem_ptr;
hmem_string_ptr += 0x14;
XplatUIWin32.Win32CopyMemory(new IntPtr(hmem_string_ptr), string_buffer, string_buffer_size);
Marshal.FreeHGlobal(string_buffer);
XplatUIWin32.Win32GlobalUnlock(hmem_ptr);
break;
}
case ClipboardFormats.CF_DIB: {
b = XplatUIWin32.ImageToDIB((Image)data);
hmem = XplatUIWin32.CopyToMoveableMemory (b);
break;
}
default: {
hmem = IntPtr.Zero;
break;
}
}
if (hmem != IntPtr.Zero) {
medium = new STGMEDIUM();
medium.tymed = TYMED.TYMED_HGLOBAL;
medium.hHandle = hmem;
medium.pUnkForRelease = IntPtr.Zero;
DragMediums.Add(medium);
format = new FORMATETC();
format.ptd = IntPtr.Zero;
format.dwAspect = DVASPECT.DVASPECT_CONTENT;
format.lindex = -1;
format.tymed = TYMED.TYMED_HGLOBAL;
format.cfFormat = cfFormat;
DragFormats.Add(format);
return true;
}
return false;
}
示例15: GetDataHere
/// <summary>
/// Gets the specified data.
/// </summary>
/// <param name="format">The requested data format.</param>
/// <param name="medium">When the function returns, contains the requested data.</param>
/// <remarks>Differs from GetData only in that the STGMEDIUM storage is
/// allocated and owned by the caller.</remarks>
public void GetDataHere(ref FORMATETC format, ref STGMEDIUM medium)
{
// Locate the data
KeyValuePair<FORMATETC, STGMEDIUM> dataEntry;
if (GetDataEntry(ref format, out dataEntry))
{
STGMEDIUM source = dataEntry.Value;
medium = CopyMedium(ref source);
return;
}
// Didn't find it. Return an empty data medium.
medium = default(STGMEDIUM);
}