mirror of https://github.com/dahall/Vanara.git
Derived from ShellCommand and now call CancelTimeout after DragDrop event fires.
parent
f5c7ecf216
commit
6c083b511f
|
@ -20,9 +20,9 @@ namespace Vanara.Windows.Shell
|
||||||
/// <item>Create a .NET application project.</item>
|
/// <item>Create a .NET application project.</item>
|
||||||
/// <item>Delete the Program.cs file that includes the Main method.</item>
|
/// <item>Delete the Program.cs file that includes the Main method.</item>
|
||||||
/// <item>Create a new class and derive it from <see cref="ShellDropTarget"/> with the attributes in the example below.</item>
|
/// <item>Create a new class and derive it from <see cref="ShellDropTarget"/> with the attributes in the example below.</item>
|
||||||
|
/// <item>Ensure the project is built as "X86".</item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// <para><b>Example:</b></para>
|
/// <code title="Example" lang="cs">[Guid("<Your GUID here>"), ClassInterface(ClassInterfaceType.None)]
|
||||||
/// <code title="Example">[Guid("<Your GUID here>"), ClassInterface(ClassInterfaceType.None)]
|
|
||||||
///public class MyDropTarget : ShellDropTarget
|
///public class MyDropTarget : ShellDropTarget
|
||||||
///{
|
///{
|
||||||
/// // In your constructor, be sure to override the DragEnter and DragDrop events and set the effect you desire.
|
/// // In your constructor, be sure to override the DragEnter and DragDrop events and set the effect you desire.
|
||||||
|
@ -77,14 +77,14 @@ namespace Vanara.Windows.Shell
|
||||||
/// new MyDropTarget().Run(TimeSpan.FromSeconds(30));
|
/// new MyDropTarget().Run(TimeSpan.FromSeconds(30));
|
||||||
/// break;
|
/// break;
|
||||||
///
|
///
|
||||||
/// // Unregister this out-of-proc server from handling the DropTarget. This can be ommitted if done by an installer.
|
/// // Unregister this out-of-proc server from handling the DropTarget. This can be omitted if done by an installer.
|
||||||
/// case "unregister":
|
/// case "unregister":
|
||||||
/// using (var progid = new ProgId(progID, false))
|
/// using (var progid = new ProgId(progID, false))
|
||||||
/// progid.Verbs.Remove(verbName);
|
/// progid.Verbs.Remove(verbName);
|
||||||
/// ShellRegistrar.UnregisterLocalServer<MyDropTarget>(false);
|
/// ShellRegistrar.UnregisterLocalServer<MyDropTarget>(false);
|
||||||
/// break;
|
/// break;
|
||||||
///
|
///
|
||||||
/// // Register this out-of-proc server to handle the DropTarget. This can be ommitted if done by an installer.
|
/// // Register this out-of-proc server to handle the DropTarget. This can be omitted if done by an installer.
|
||||||
/// default:
|
/// default:
|
||||||
/// ShellRegistrar.RegisterLocalServer<MyDropTarget>("MyTestDropTarget", systemWide: false);
|
/// ShellRegistrar.RegisterLocalServer<MyDropTarget>("MyTestDropTarget", systemWide: false);
|
||||||
/// using (var progid = new ProgId(progID, false))
|
/// using (var progid = new ProgId(progID, false))
|
||||||
|
@ -99,7 +99,7 @@ namespace Vanara.Windows.Shell
|
||||||
///}</code></remarks>
|
///}</code></remarks>
|
||||||
/// <seealso cref="Vanara.Windows.Shell.ComObject"/>
|
/// <seealso cref="Vanara.Windows.Shell.ComObject"/>
|
||||||
/// <seealso cref="Vanara.PInvoke.Ole32.IDropTarget"/>
|
/// <seealso cref="Vanara.PInvoke.Ole32.IDropTarget"/>
|
||||||
public abstract class ShellDropTarget : ComObject, IDropTarget, IInitializeCommand
|
public abstract class ShellDropTarget : ShellCommand, IDropTarget, IInitializeCommand
|
||||||
{
|
{
|
||||||
private DataObject lastDataObject;
|
private DataObject lastDataObject;
|
||||||
private DROPEFFECT lastEffect = DROPEFFECT.DROPEFFECT_NONE;
|
private DROPEFFECT lastEffect = DROPEFFECT.DROPEFFECT_NONE;
|
||||||
|
@ -127,20 +127,6 @@ namespace Vanara.Windows.Shell
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event DragEventHandler DragOver;
|
public event DragEventHandler DragOver;
|
||||||
|
|
||||||
/// <summary>Gets the name of the command returned by <c>IInitializeCommand.Initialize</c>.</summary>
|
|
||||||
/// <value>
|
|
||||||
/// The name of the command as found in the registry. This value is <see langword="null"/> until <c>IInitializeCommand.Initialize</c>
|
|
||||||
/// is called by the host.
|
|
||||||
/// </value>
|
|
||||||
public string CommandName { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>Gets the properties exposed through <c>IInitializeCommand.Initialize</c>.</summary>
|
|
||||||
/// <value>
|
|
||||||
/// Gets a <see cref="PropertyBag"/> instance. This value is <see langword="null"/> until <c>IInitializeCommand.Initialize</c> is
|
|
||||||
/// called by the host.
|
|
||||||
/// </value>
|
|
||||||
public PropertyBag Properties { get; private set; }
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
HRESULT IDropTarget.DragEnter(IDataObject pDataObj, uint grfKeyState, Point pt, ref DROPEFFECT pdwEffect)
|
HRESULT IDropTarget.DragEnter(IDataObject pDataObj, uint grfKeyState, Point pt, ref DROPEFFECT pdwEffect)
|
||||||
{
|
{
|
||||||
|
@ -177,14 +163,7 @@ namespace Vanara.Windows.Shell
|
||||||
var drgevent = CreateDragEventArgs(pDataObj, grfKeyState, pt, pdwEffect);
|
var drgevent = CreateDragEventArgs(pDataObj, grfKeyState, pt, pdwEffect);
|
||||||
DragDrop?.Invoke(this, drgevent);
|
DragDrop?.Invoke(this, drgevent);
|
||||||
pdwEffect = (DROPEFFECT)drgevent.Effect;
|
pdwEffect = (DROPEFFECT)drgevent.Effect;
|
||||||
return HRESULT.S_OK;
|
CancelTimeout();
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
HRESULT IInitializeCommand.Initialize(string pszCommandName, IPropertyBag ppb)
|
|
||||||
{
|
|
||||||
CommandName = pszCommandName;
|
|
||||||
Properties = new PropertyBag(ppb);
|
|
||||||
return HRESULT.S_OK;
|
return HRESULT.S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue