Added/updated shell progress dialog interface variants along with documentation.

pull/10/head
David Hall 2018-07-30 15:51:51 -06:00
parent 58b608868e
commit dd64445572
3 changed files with 634 additions and 38 deletions

View File

@ -0,0 +1,178 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Flags that indicate the action to be taken by the ProgressDialog.SetTime() method.</summary>
[PInvokeData("Shlobj_core.h", MSDNShortId = "bb775248")]
public enum PDTIMER : uint
{
/// <summary>Resets the timer to zero. Progress will be calculated from the time this method is called.</summary>
PDTIMER_RESET = (0x01),
/// <summary>Progress has been suspended.</summary>
PDTIMER_PAUSE = (0x02),
/// <summary>Progress has been resumed.</summary>
PDTIMER_RESUME = (0x03)
}
/// <summary>Defines a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</summary>
/// <summary>Flags that control the operation of the progress dialog box.</summary>
[PInvokeData("Shlobj_core.h", MSDNShortId = "bb775248")]
[Flags]
public enum PROGDLG : uint
{
/// <summary>Normal progress dialog box behavior.</summary>
PROGDLG_NORMAL = 0x00000000,
/// <summary>
/// The progress dialog box will be modal to the window specified by hwndParent. By default, a progress dialog box is modeless.
/// </summary>
PROGDLG_MODAL = 0x00000001,
/// <summary>Automatically estimate the remaining time and display the estimate on line 3.</summary>
/// <remarks>If this flag is set, IProgressDialog::SetLine can be used only to display text on lines 1 and 2.</remarks>
PROGDLG_AUTOTIME = 0x00000002,
/// <summary>Do not show the "time remaining" text.</summary>
PROGDLG_NOTIME = 0x00000004,
/// <summary>Do not display a minimize button on the dialog box's caption bar.</summary>
PROGDLG_NOMINIMIZE = 0x00000008,
/// <summary>Do not display a progress bar.</summary>
/// <remarks>
/// Typically, an application can quantitatively determine how much of the operation remains and periodically pass that value to
/// IProgressDialog::SetProgress. The progress dialog box uses this information to update its progress bar. This flag is
/// typically set when the calling application must wait for an operation to finish, but does not have any quantitative
/// information it can use to update the dialog box.
/// </remarks>
PROGDLG_NOPROGRESSBAR = 0x00000010,
/// <summary>Sets the progress bar to marquee mode.</summary>
/// <remarks>
/// This causes the progress bar to scroll horizontally, similar to a marquee display. Use this when you wish to indicate that
/// progress is being made, but the time required for the operation is unknown.
/// </remarks>
PROGDLG_MARQUEEPROGRESS = 0x00000020,
/// <summary>Do not display a cancel button.</summary>
/// <remarks>The operation cannot be canceled. Use this only when absolutely necessary.</remarks>
PROGDLG_NOCANCEL = 0x00000040
}
/// <summary>
/// Exposes methods that provide options for an application to display a progress dialog box. This interface is exported by the
/// progress dialog box object (CLSID_ProgressDialog). This object is a generic way to show a user how an operation is progressing.
/// It is typically used when deleting, uploading, copying, moving, or downloading large numbers of files.
/// </summary>
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775248(v=vs.85).aspx
[PInvokeData("Shlobj_core.h", MSDNShortId = "bb775248")]
[ComImport, Guid("EBBC7C04-315E-11d2-B62F-006097DF5BD4"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ProgressDialog))]
public interface IProgressDialog
{
/// <summary>Starts the progress dialog box.</summary>
/// <param name="hwndParent">A handle to the dialog box's parent window.</param>
/// <param name="punkEnableModless">Reserved. Set to null.</param>
/// <param name="dwFlags">Flags that control the operation of the progress dialog box.</param>
/// <param name="pvResevered">Reserved. Set to IntPtr.Zero</param>
void StartProgressDialog(IntPtr hwndParent, [MarshalAs(UnmanagedType.IUnknown), Optional] object punkEnableModless, PROGDLG dwFlags, IntPtr pvResevered = default(IntPtr));
/// <summary>Stops the progress dialog box and removes it from the screen.</summary>
void StopProgressDialog();
/// <summary>Sets the title of the progress dialog box.</summary>
/// <param name="pwzTitle">A pointer to a null-terminated Unicode string that contains the dialog box title.</param>
void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pwzTitle);
/// <summary>
/// Specifies an Audio-Video Interleaved (AVI) clip that runs in the dialog box. Note: Note This method is not supported in
/// Windows Vista or later versions.
/// </summary>
/// <param name="hInstAnimation">An instance handle to the module from which the AVI resource should be loaded.</param>
/// <param name="idAnimation">
/// An AVI resource identifier. To create this value, use the MAKEINTRESOURCE macro. The control loads the AVI resource from the
/// module specified by hInstAnimation.
/// </param>
void SetAnimation(IntPtr hInstAnimation, ushort idAnimation);
/// <summary>Checks whether the user has canceled the operation.</summary>
/// <returns>TRUE if the user has canceled the operation; otherwise, FALSE.</returns>
/// <remarks>
/// The system does not send a message to the application when the user clicks the Cancel button. You must periodically use this
/// function to poll the progress dialog box object to determine whether the operation has been canceled.
/// </remarks>
[PreserveSig]
[return: MarshalAs(UnmanagedType.Bool)]
bool HasUserCancelled();
/// <summary>Updates the progress dialog box with the current state of the operation.</summary>
/// <param name="dwCompleted">
/// An application-defined value that indicates what proportion of the operation has been completed at the time the method was called.
/// </param>
/// <param name="dwTotal">
/// An application-defined value that specifies what value dwCompleted will have when the operation is complete.
/// </param>
void SetProgress(uint dwCompleted, uint dwTotal);
/// <summary>Updates the progress dialog box with the current state of the operation.</summary>
/// <param name="ullCompleted">
/// An application-defined value that indicates what proportion of the operation has been completed at the time the method was called.
/// </param>
/// <param name="ullTotal">
/// An application-defined value that specifies what value ullCompleted will have when the operation is complete.
/// </param>
void SetProgress64(ulong ullCompleted, ulong ullTotal);
/// <summary>Displays a message in the progress dialog.</summary>
/// <param name="dwLineNum">
/// The line number on which the text is to be displayed. Currently there are three lines—1, 2, and 3. If the PROGDLG_AUTOTIME
/// flag was included in the dwFlags parameter when IProgressDialog::StartProgressDialog was called, only lines 1 and 2 can be
/// used. The estimated time will be displayed on line 3.
/// </param>
/// <param name="pwzString">A null-terminated Unicode string that contains the text.</param>
/// <param name="fCompactPath">
/// TRUE to have path strings compacted if they are too large to fit on a line. The paths are compacted with PathCompactPath.
/// </param>
/// <param name="pvResevered">Reserved. Set to IntPtr.Zero.</param>
/// <remarks>
/// This function is typically used to display a message such as "Item XXX is now being processed." typically, messages are
/// displayed on lines 1 and 2, with line 3 reserved for the estimated time.
/// </remarks>
void SetLine(uint dwLineNum, [MarshalAs(UnmanagedType.LPWStr)] string pwzString, [MarshalAs(UnmanagedType.VariantBool)] bool fCompactPath, IntPtr pvResevered = default(IntPtr));
/// <summary>Sets a message to be displayed if the user cancels the operation.</summary>
/// <param name="pwzCancelMsg">A pointer to a null-terminated Unicode string that contains the message to be displayed.</param>
/// <param name="pvResevered">Reserved. Set to NULL.</param>
/// <remarks>
/// Even though the user clicks Cancel, the application cannot immediately call IProgressDialog::StopProgressDialog to close the
/// dialog box. The application must wait until the next time it calls IProgressDialog::HasUserCancelled to discover that the
/// user has canceled the operation. Since this delay might be significant, the progress dialog box provides the user with
/// immediate feedback by clearing text lines 1 and 2 and displaying the cancel message on line 3. The message is intended to let
/// the user know that the delay is normal and that the progress dialog box will be closed shortly. It is typically is set to
/// something like "Please wait while ...".
/// </remarks>
void SetCancelMsg([MarshalAs(UnmanagedType.LPWStr)] string pwzCancelMsg, IntPtr pvResevered = default(IntPtr));
/// <summary>Resets the progress dialog box timer to zero.</summary>
/// <param name="dwTimerAction">Flags that indicate the action to be taken by the timer.</param>
/// <param name="pvResevered">Reserved. Set to NULL.</param>
/// <remarks>
/// The timer is used to estimate the remaining time. It is started when your application calls
/// IProgressDialog::StartProgressDialog. Unless your application will start immediately, it should call Timer just before
/// starting the operation. This practice ensures that the time estimates will be as accurate as possible. This method should not
/// be called after the first call to IProgressDialog::SetProgress.
/// </remarks>
void Timer(PDTIMER dwTimerAction, IntPtr pvResevered = default(IntPtr));
}
/// <summary>Class object for IProgressDialog (CLSID_ProgressDialog).</summary>
[ComImport, Guid("F8383852-FCD3-11d1-A6B9-006097DF5BD4"), ClassInterface(ClassInterfaceType.None)]
public class ProgressDialog
{
}
}
}

View File

@ -0,0 +1,228 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>
/// <para>Used by IActionProgress::Begin, these constants specify certain UI operations that are to be enabled or disabled.</para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-_spbeginf
[PInvokeData("shobjidl_core.h", MSDNShortId = "dc5215ca-17c8-47c1-8059-f46400ff1d0f")]
[Flags]
public enum SPBEGINF : uint
{
/// <summary>Indicates default progress behavior.</summary>
SPBEGINF_NORMAL = 0x00000000,
/// <summary>
/// Indicates that the progress UI should automatically update a text field with the amount of time remaining until the action completes.
/// </summary>
SPBEGINF_AUTOTIME = 0x00000002,
/// <summary>Indicates that the UI should not display a progress bar.</summary>
SPBEGINF_NOPROGRESSBAR = 0x00000010,
/// <summary>Indicates that the UI should use a marquee-style progress bar.</summary>
SPBEGINF_MARQUEEPROGRESS = 0x00000020,
/// <summary>Indicates that the UI should not include a Cancel button.</summary>
SPBEGINF_NOCANCELBUTTON = 0x00000040,
}
/// <summary>Flags used by IActionProgressDialog::Initialize</summary>
[PInvokeData("shobjidl_core.h")]
public enum SPINITF
{
/// <summary>Use the default progress dialog behavior.</summary>
SPINITF_NORMAL = 0x00000000,
/// <summary>Use a modal window for the dialog.</summary>
SPINITF_MODAL = 0x00000001,
/// <summary>Do not display a minimize button.</summary>
SPINITF_NOMINIMIZE = 0x00000008,
}
/// <summary>
/// <para>Specifies the type of descriptive text being provided to an IActionProgress interface.</para>
/// </summary>
[PInvokeData("shobjidl_core.h", MSDNShortId = "3d33cb3a-5949-446c-97ec-7ac4f4b1f675")]
public enum SPTEXT
{
/// <summary>The text is a high level, short description.</summary>
SPTEXT_ACTIONDESCRIPTION = 1,
/// <summary>The text is a detailed description.</summary>
SPTEXT_ACTIONDETAIL,
}
/// <summary>
/// <para>Represents the abstract base class from which progress-driven operations can inherit.</para>
/// </summary>
/// <remarks>
/// <para>
/// This class is an abstract class that may not be instantiated. It provides a framework that derived classes can use to implement a
/// progress callback. This callback can be used by applications to report progress of actions to the UI. Here, "Actions" refers to
/// operations that may take a significant amount of time, such as downloading or copying files, and during which a visible progress
/// indication would be appropriate.
/// </para>
/// <para>
/// Applications typically do not implement this interface. Much of the functionality that users interact with during actions is
/// provided by the CProgressDialog class (CLSID_ProgressDialog) that implements <c>IActionProgress</c> and displays progress in a
/// dialog box. If a solution requiring a mechanism other than a dialog box is required, <c>IActionProgress</c> can be used to
/// provide basic progress indicator functionality.
/// </para>
/// <para>
/// Once implemented, classes should call IActionProgress::Begin when an action is started. Periodically,
/// IActionProgress::UpdateProgress should be called to update the UI with progress information, and detailed textual information
/// should be conveyed to the UI by calling IActionProgress::UpdateText. IActionProgress::QueryCancel and
/// IActionProgress::ResetCancel should be called to handle cancellation requests. Once the operation ends, IActionProgress::End
/// should be called.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iactionprogress
[PInvokeData("shobjidl_core.h", MSDNShortId = "e742e381-0fd2-482a-81a0-7b43d11b073b")]
[ComImport, Guid("49ff1173-eadc-446d-9285-156453a6431c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ProgressDialog))]
public interface IActionProgress
{
/// <summary>
/// <para>Called when an action has begun that requires its progress be displayed to the user.</para>
/// </summary>
/// <param name="action">
/// <para>Type: <c>SPACTION</c></para>
/// <para>The action being performed. See SPACTION for a list of acceptable values.</para>
/// </param>
/// <param name="flags">
/// <para>Type: <c>SPBEGINF</c></para>
/// <para>Optional flags that request certain UI operations be enabled or disabled. See SPBEGINF for a list of acceptable values.</para>
/// </param>
/// <remarks>
/// <para>
/// This method should be called when an action is beginning. The values of and may be used to determine how to draw the UI that
/// will be displayed to the user, or how to interpret or filter certain user actions associated with the action. When the action
/// has completed, IActionProgress::End should be called.
/// </para>
/// </remarks>
void Begin(SPACTION action, SPBEGINF flags);
/// <summary>
/// <para>Updates the progress of an action to the UI.</para>
/// </summary>
/// <param name="ulCompleted">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>The amount of the action completed.</para>
/// </param>
/// <param name="ulTotal">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>The total amount of the action.</para>
/// </param>
/// <remarks>
/// <para>
/// This method should be called periodically to update the progress of the action. The implementing class may interpret these
/// values in any way desired, although the values of and should be interpreted relative to one another to determine a meaningful
/// progress amount. Often, a percentage is desired, in which case the value of should be divided by , and the result multiplied
/// by a value of 100.
/// </para>
/// </remarks>
void UpdateProgress(ulong ulCompleted, ulong ulTotal);
/// <summary>
/// <para>Called if descriptive text associated with the action will be changed.</para>
/// </summary>
/// <param name="sptext">
/// <para>Type: <c>SPTEXT</c></para>
/// <para>A value that specifies the type of text displayed. See SPTEXT for acceptable values.</para>
/// </param>
/// <param name="pszText">
/// <para>Type: <c>LPCWSTR</c></para>
/// <para>A pointer to a wide character string to display.</para>
/// </param>
/// <param name="fMayCompact">
/// <para>Type: <c>BOOL</c></para>
/// <para>A value that specifies whether to allow a text string to be compacted to fit the available space on screen.</para>
/// </param>
/// <remarks>
/// <para>
/// The class implementing this method must interpret the value of and in the context of the action being performed and the UI
/// that shows the progress to the user. The value of can be used to differentiate between lines of changeable text. Often, the
/// value of refers to whether the text string can be truncated with an ellipsis (...) in order to conserve screen space.
/// </para>
/// </remarks>
void UpdateText(SPTEXT sptext, [In, MarshalAs(UnmanagedType.LPWStr)] string pszText, [MarshalAs(UnmanagedType.Bool)] bool fMayCompact);
/// <summary>
/// <para>Provides information about whether the action is being canceled.</para>
/// </summary>
/// <returns>
/// <para>A reference to a <c>BOOL</c> value that specifies whether the action is being canceled.</para>
/// </returns>
/// <remarks>
/// <para>
/// Call this method when a process must know whether an action has been canceled. Implementing this method requires the
/// implementing class to query either an internal or external flag to provide this information, and store the result in the
/// value of .
/// </para>
/// </remarks>
bool QueryCancel();
/// <summary>
/// <para>Resets progress dialog after a cancellation has been completed.</para>
/// </summary>
/// <remarks>
/// <para>
/// This method is called when a cancellation has been completed. User input should typically be limited for cancellations of
/// actions that involve large calculations or file operations. This method may be used by calling applications to notify a
/// progress UI that the cancellation has been completed and the UI should return control to the user.
/// </para>
/// </remarks>
void ResetCancel();
/// <summary>
/// <para>Indicates that the action associated with this progress implementation has ended.</para>
/// </summary>
/// <remarks>
/// <para>
/// This method indicates that the action has finished, and the implementing class should perform cleanup and display results to
/// the user, if applicable.
/// </para>
/// </remarks>
void End();
}
/// <summary>Exposes methods that initialize and stop a progress dialog.</summary>
/// <remarks>
/// To instantiate an object that implements this interface, call CoCreateInstance using the class identifier (CLSID) CLSID_ProgressDialog.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iactionprogressdialog
[PInvokeData("shobjidl_core.h", MSDNShortId = "f3c0e4ae-f93f-4ee2-873a-d9370044e922")]
[ComImport, Guid("49ff1172-eadc-446d-9285-156453a6431c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ProgressDialog))]
public interface IActionProgressDialog
{
/// <summary>Provides details about the action progress dialog.</summary>
/// <param name="flags">
/// <para>Type: <c>SPINITF</c></para>
/// <para>One of the following values.</para>
/// <para>SPINITF_NORMAL (0x01)</para>
/// <para>Use the default progress dialog behavior.</para>
/// <para>SPINITF_MODAL (0x01)</para>
/// <para>Use a modal window for the dialog.</para>
/// <para>SPINITF_NOMINIMIZE (0x08)</para>
/// <para>Do not display a minimize button.</para>
/// </param>
/// <param name="pszTitle">
/// <para>Type: <c>LPCWSTR</c></para>
/// <para>The title of the progress dialog.</para>
/// </param>
/// <param name="pszCancel">
/// <para>Type: <c>LPCWSTR</c></para>
/// <para>The string displayed when a user closes the dialog before completion.</para>
/// </param>
void Initialize(SPINITF flags, [In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle, [In, MarshalAs(UnmanagedType.LPWStr)] string pszCancel);
/// <summary>Stops a progress dialog.</summary>
void Stop();
}
}
}

View File

@ -1,103 +1,293 @@
using System;
using System.Runtime.InteropServices;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedParameter.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberHidesStaticFromOuterClass
// ReSharper disable UnusedMethodReturnValue.Global
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Flags used in IOperationsProgressDialog::StartProgressDialog</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ioperationsprogressdialog-startprogressdialog
[PInvokeData("shobjidl_core.h", MSDNShortId = "5d6f44e0-259f-42d3-9912-877d90f0e7fc")]
[Flags]
public enum OPPROGDLGF
{
// The flag space includes OPPROGDLG_ and PROGDLG_ values
// please guarantee they don't conflict. See shlobj.w for PROGDLG_*
/// <summary>Default operation.</summary>
OPPROGDLG_DEFAULT = 0x00000000,
OPPROGDLG_ENABLEPAUSE = 0x00000080, // Add a pause button (operation can be paused)
OPPROGDLG_ALLOWUNDO = 0x00000100, // The operation can be undone in the dialog. (The Stop button becomes Undo)
OPPROGDLG_DONTDISPLAYSOURCEPATH = 0x00000200, // Don't display the path of source file in progress dialog
OPPROGDLG_DONTDISPLAYDESTPATH = 0x00000400, // Don't display the path of destination file in progress dialog
OPPROGDLG_NOMULTIDAYESTIMATES = 0x00000800, // deprecated - progress dialog no longer displays > 1 day estimates
OPPROGDLG_DONTDISPLAYLOCATIONS = 0x00001000, // Don't display the location line in the progress dialog
/// <summary>Add a pause button (operation can be paused)</summary>
OPPROGDLG_ENABLEPAUSE = 0x00000080,
/// <summary>The operation can be undone in the dialog. (The Stop button becomes Undo)</summary>
OPPROGDLG_ALLOWUNDO = 0x00000100,
/// <summary>Don't display the path of source file in progress dialog</summary>
OPPROGDLG_DONTDISPLAYSOURCEPATH = 0x00000200,
/// <summary>Don't display the path of destination file in progress dialog</summary>
OPPROGDLG_DONTDISPLAYDESTPATH = 0x00000400,
/// <summary>deprecated - progress dialog no longer displays &gt; 1 day estimates</summary>
OPPROGDLG_NOMULTIDAYESTIMATES = 0x00000800,
/// <summary>Don't display the location line in the progress dialog</summary>
OPPROGDLG_DONTDISPLAYLOCATIONS = 0x00001000,
}
/// <summary>Flags used in IOperationsProgressDialog::SetMode</summary>
[PInvokeData("shobjidl_core.h")]
[Flags]
public enum PDMODE
{
/// <summary>0x00000000. Use the default progress dialog operations mode.</summary>
PDM_DEFAULT = 0x00000000,
PDM_RUN = 0x00000001, // Operation is running
PDM_PREFLIGHT = 0x00000002, // Pre-flight mode, calculating operation time, etc
PDM_UNDOING = 0x00000004, // Operation is rolling back, undo has been selected
PDM_ERRORSBLOCKING = 0x00000008, // Only errors remain, error dialogs are blocking progress from completing
PDM_INDETERMINATE = 0x00000010, // The length of the operation is indeterminate, don't show a timer, progressbar is in marquee mode
/// <summary>0x00000001. The operation is running.</summary>
PDM_RUN = 0x00000001,
/// <summary>0x00000002. The operation is gathering data before it begins, such as calculating the predicted operation time.</summary>
PDM_PREFLIGHT = 0x00000002,
/// <summary>0x00000004. The operation is rolling back due to an Undo command from the user.</summary>
PDM_UNDOING = 0x00000004,
/// <summary>0x00000008. Error dialogs are blocking progress from continuing.</summary>
PDM_ERRORSBLOCKING = 0x00000008,
/// <summary>
/// 0x00000010. The length of the operation is indeterminate. Do not show a timer and display the progress bar in marquee mode.
/// </summary>
PDM_INDETERMINATE = 0x00000010,
}
/// <summary>Provides operation status flags for IOperationsProgressDialog::GetOperationStatus</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-pdopstatus typedef enum PDOPSTATUS {
// PDOPS_RUNNING , PDOPS_PAUSED , PDOPS_CANCELLED , PDOPS_STOPPED , PDOPS_ERRORS } ;
[PInvokeData("shobjidl_core.h", MSDNShortId = "f9fd5cbe-2cb7-4ae7-9cf2-f8545095eec8")]
public enum PDOPSTATUS
{
PDOPS_RUNNING = 1, // Operation is running, no user intervention
PDOPS_PAUSED = 2, // Operation has been paused by the user
PDOPS_CANCELLED = 3, // Operation has been cancelled by the user - now go undo
PDOPS_STOPPED = 4, // Operation has been stopped by the user - terminate completely
PDOPS_ERRORS = 5, // Operation has gone as far as it can without throwing error dialogs
/// <summary>Operation is running, no user intervention.</summary>
PDOPS_RUNNING = 1,
/// <summary>Operation has been paused by the user.</summary>
PDOPS_PAUSED = 2,
/// <summary>Operation has been canceled by the user - now go undo.</summary>
PDOPS_CANCELLED = 3,
/// <summary>Operation has been stopped by the user - terminate completely.</summary>
PDOPS_STOPPED = 4,
/// <summary>Operation has gone as far as it can go without throwing error dialogs.</summary>
PDOPS_ERRORS = 5,
}
/// <summary>
/// <para>Describes an action being performed that requires progress to be shown to the user using an IActionProgress interface.</para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-_spaction
[PInvokeData("shobjidl_core.h", MSDNShortId = "fc5a0f96-e8c2-483f-86b0-d8c870a9f77a")]
public enum SPACTION
{
SPACTION_NONE = 0,
/// <summary>No action is being performed.</summary>
SPACTION_NONE,
/// <summary>Files are being moved.</summary>
SPACTION_MOVING,
/// <summary>Files are being copied.</summary>
SPACTION_COPYING,
/// <summary>Files are being deleted.</summary>
SPACTION_RECYCLING,
/// <summary>A set of attributes are being applied to files.</summary>
SPACTION_APPLYINGATTRIBS,
/// <summary>A file is being downloaded from a remote source.</summary>
SPACTION_DOWNLOADING,
/// <summary>An Internet search is being performed.</summary>
SPACTION_SEARCHING_INTERNET,
/// <summary>A calculation is being performed.</summary>
SPACTION_CALCULATING,
/// <summary>A file is being uploaded to a remote source.</summary>
SPACTION_UPLOADING,
/// <summary>A local search is being performed.</summary>
SPACTION_SEARCHING_FILES,
/// <summary>Windows Vista and later. A deletion is being performed.</summary>
SPACTION_DELETING,
/// <summary>Windows Vista and later. A renaming action is being performed.</summary>
SPACTION_RENAMING,
/// <summary>Windows Vista and later. A formatting action is being performed.</summary>
SPACTION_FORMATTING,
SPACTION_COPY_MOVING
/// <summary>Windows 7 and later. A copy or move action is being performed.</summary>
SPACTION_COPY_MOVING,
}
[ComImport, Guid("0C9FB851-E5C9-43EB-A370-F0677B13874C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
/// <summary>Exposes methods to get, set, and query a progress dialog.</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ioperationsprogressdialog
[PInvokeData("shobjidl_core.h", MSDNShortId = "0d95f407-0e09-441d-b9e2-665995ea1362")]
[ComImport, Guid("0C9FB851-E5C9-43EB-A370-F0677B13874C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ProgressDialog))]
public interface IOperationsProgressDialog
{
/// <summary>
/// <para>Starts the specified progress dialog.</para>
/// </summary>
/// <param name="hwndOwner">
/// <para>Type: <c>HWND</c></para>
/// <para>A handle to the parent window.</para>
/// </param>
/// <param name="flags"/>
/// <remarks>
/// <para>
/// The progress dialog should be created on a separate thread than the file operation on which the dialog is reporting. If the
/// dialog is running in the same thread as the file operation, progress messages are, at best, only sent as resources allow.
/// Progress messages on the same thread as the file operation might not be sent at all.
/// </para>
/// <para>
/// Once <c>IOperationsProgressDialog::StartProgressDialog</c> is called, that instance of the <c>CLSID_ProgressDialog</c> object
/// cannot be accessed by IProgressDialog, IActionProgressDialog, or IActionProgress. Although QueryInterface can be used to
/// access these interfaces, most of their methods cannot be invoked. IOperationsProgressDialog is the interface used to display
/// the new progress dialog for the Windows Vista and later operations engine.
/// </para>
/// </remarks>
void StartProgressDialog([In] IntPtr hwndOwner, [In] OPPROGDLGF flags);
/// <summary>Stops current progress dialog.</summary>
void StopProgressDialog();
// Sets which operation is occuring, and whether we are In pre-flight or undo mode - sets animations, text, etc.
/// <summary>
/// <para>Sets which progress dialog operation is occurring, and whether we are in pre-flight or undo mode.</para>
/// </summary>
/// <param name="action">
/// <para>Type: <c>SPACTION</c></para>
/// <para>Specifies operation. See SPACTION.</para>
/// </param>
void SetOperation([In] SPACTION action);
/// <summary>
/// <para>Sets progress dialog operations mode.</para>
/// </summary>
/// <param name="mode">
/// <para>Type: <c>PDMODE</c></para>
/// <para>Specifies the operation mode. The following are valid values.</para>
/// <para>PDM_DEFAULT</para>
/// <para>0x00000000. Use the default progress dialog operations mode.</para>
/// <para>PDM_RUN</para>
/// <para>0x00000001. The operation is running.</para>
/// <para>PDM_PREFLIGHT</para>
/// <para>0x00000002. The operation is gathering data before it begins, such as calculating the predicted operation time.</para>
/// <para>PDM_UNDOING</para>
/// <para>0x00000004. The operation is rolling back due to an Undo command from the user.</para>
/// <para>PDM_ERRORSBLOCKING</para>
/// <para>0x00000008. Error dialogs are blocking progress from continuing.</para>
/// <para>PDM_INDETERMINATE</para>
/// <para>
/// 0x00000010. The length of the operation is indeterminate. Do not show a timer and display the progress bar in marquee mode.
/// </para>
/// </param>
void SetMode([In] PDMODE mode);
/// <summary>
/// <para>Updates the current progress dialog, as specified.</para>
/// </summary>
/// <param name="ullPointsCurrent">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Current points, used for showing progress in points.</para>
/// </param>
/// <param name="ullPointsTotal">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Total points, used for showing progress in points.</para>
/// </param>
/// <param name="ullSizeCurrent">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Current size in bytes, used for showing progress in bytes.</para>
/// </param>
/// <param name="ullSizeTotal">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Total size in bytes, used for showing progress in bytes.</para>
/// </param>
/// <param name="ullItemsCurrent">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Current items, used for showing progress in items.</para>
/// </param>
/// <param name="ullItemsTotal">
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Specifies total items, used for showing progress in items.</para>
/// </param>
void UpdateProgress(
[In] ulong ullPointsCurrent,
[In] ulong ullPointsTotal,
[In] ulong ullSizeCurrent,
[In] ulong ullSizeTotal,
[In] ulong ullItemsCurrent,
[In] ulong ullItemsTotal);
[In] ulong ullPointsTotal,
[In] ulong ullSizeCurrent,
[In] ulong ullSizeTotal,
[In] ulong ullItemsCurrent,
[In] ulong ullItemsTotal);
// Used to generate display for "from <item (path)> to <item (path)>", etc.
/// <summary>
/// <para>Called to specify the text elements stating the source and target in the current progress dialog.</para>
/// </summary>
/// <param name="psiSource">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>A pointer to an IShellItem that represents the source Shell item.</para>
/// </param>
/// <param name="psiTarget">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>A pointer to an IShellItem that represents the target Shell item.</para>
/// </param>
/// <param name="psiItem">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>
/// A pointer to an IShellItem that represents the item currently being operated on by the operation engine. This parameter is
/// only used in Windows 7 and later. In earlier versions, this parameter should be <c>NULL</c>.
/// </para>
/// </param>
void UpdateLocations(
[In] IShellItem psiSource,
[In] IShellItem psiTarget,
[In] IShellItem psiItem);
[In, Optional] IShellItem psiItem);
/// <summary>
/// <para>Resets progress dialog timer to 0.</para>
/// </summary>
void ResetTimer();
/// <summary>
/// <para>Pauses progress dialog timer.</para>
/// </summary>
void PauseTimer();
/// <summary>
/// <para>Resumes progress dialog timer.</para>
/// </summary>
void ResumeTimer();
/// <summary>
/// <para>Gets elapsed and remaining time for progress dialog.</para>
/// </summary>
/// <param name="pullElapsed">
/// <para>Type: <c>ULONGLONG*</c></para>
/// <para>A pointer to the elapsed time in milliseconds.</para>
/// </param>
/// <param name="pullRemaining">
/// <para>Type: <c>ULONGLONG*</c></para>
/// <para>A pointer to the remaining time in milliseconds.</para>
/// </param>
void GetMilliseconds(out ulong pullElapsed, out ulong pullRemaining);
// Returns running/paused/cancelled, etc.
/// <summary>
/// <para>Gets operation status for progress dialog.</para>
/// </summary>
/// <returns>
/// <para>Type: <c>PDOPSTATUS*</c></para>
/// <para>Contains pointer to the operation status. See PDOPSTATUS.</para>
/// </returns>
PDOPSTATUS GetOperationStatus();
}
}