using System; using System.Runtime.InteropServices; using System.Text; namespace Vanara.PInvoke { public static partial class Shell32 { /// A value that controls the behavior of the view when in common dialog mode. [Flags] [PInvokeData("Shobjidl.h")] public enum CDB2GVF { /// All files, including hidden and system files, should be shown. In Windows XP, this is the only recognized flag. CDB2GVF_SHOWALLFILES = 0x00000001, /// This browser is designated to choose a file to save. CDB2GVF_ISFILESAVE = 0x00000002, /// Not used. CDB2GVF_ALLOWPREVIEWPANE = 0x00000004, /// Do not show a "select" verb on an item's context menu. CDB2GVF_NOSELECTVERB = 0x00000008, /// IncludeObject should not be called. CDB2GVF_NOINCLUDEITEM = 0x00000010, /// This browser is designated to pick folders. CDB2GVF_ISFOLDERPICKER = 0x00000020, /// Windows 7 and later. Displays a UAC shield on the selected item when CDB2GVF_NOSELECTVERB is not specified. CDB2GVF_ADDSHIELD = 0x00000040, } /// Values for ICommDlgBrowser2::Notify method. [PInvokeData("Shobjidl.h")] public enum CDB2N { /// Indicates that the shortcut menu is no longer displayed. CDB2N_CONTEXTMENU_DONE = 0x00000001, /// Indicates that the shortcut menu is about to be displayed. CDB2N_CONTEXTMENU_START = 0x00000002 } /// Indicates a change in the selection state in ICommDlgBrowser::OnStateChange. [PInvokeData("Shobjidl.h")] public enum CDBOSC { /// The focus has been set to the view. CDBOSC_SETFOCUS = 0x00000000, /// The view has lost the focus. CDBOSC_KILLFOCUS = 0x00000001, /// The selection has changed. CDBOSC_SELCHANGE = 0x00000002, /// An item has been renamed. CDBOSC_RENAME = 0x00000003, /// An item has been checked or unchecked. CDBOSC_STATECHANGE = 0x00000004, } /// /// Exposed by the common file dialog boxes to be used when they host a Shell browser. If supported, ICommDlgBrowser exposes methods /// that allow a Shell view to handle several cases that require different behavior in a dialog box than in a normal Shell view. You /// obtain an ICommDlgBrowser interface pointer by calling QueryInterface on the IShellBrowser object. /// [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F1-0000-0000-C000-000000000046")] [PInvokeData("Shobjidl.h", MSDNShortId = "bf89ac6e-6c2e-4944-885c-9ab62f58fe71")] public interface ICommDlgBrowser { /// Called when a user double-clicks in the view or presses the ENTER key. /// A pointer to the view's IShellView interface. void OnDefaultCommand([In] IShellView ppshv); /// Called after a state, identified by the uChange parameter, has changed in the IShellView interface. /// A pointer to the view's IShellView interface. /// Change in the selection state. This parameter can be one of the following values. void OnStateChange([In] IShellView ppshv, CDBOSC uChange); /// Allows the common dialog box to filter objects that the view displays. /// A pointer to the view's IShellView interface. /// A PIDL, relative to the folder, that identifies the object. /// The browser should return S_OK to include the object in the view, or S_FALSE to hide it. [PreserveSig] HRESULT IncludeObject([In] IShellView ppshv, PIDL pidl); } /// /// Extends the capabilities of ICommDlgBrowser. This interface is exposed by the common file dialog boxes when they host a Shell /// browser. A pointer to ICommDlgBrowser2 can be obtained by calling QueryInterface on the IShellBrowser object. /// /// [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("10339516-2894-11d2-9039-00C04F8EEB3E")] [PInvokeData("Shobjidl.h", MSDNShortId = "07a416a2-340d-4308-a6f3-cf6f19f3c906")] public interface ICommDlgBrowser2 : ICommDlgBrowser { /// Called when a user double-clicks in the view or presses the ENTER key. /// A pointer to the view's IShellView interface. new void OnDefaultCommand([In] IShellView ppshv); /// Called after a state, identified by the uChange parameter, has changed in the IShellView interface. /// A pointer to the view's IShellView interface. /// Change in the selection state. This parameter can be one of the following values. new void OnStateChange([In] IShellView ppshv, CDBOSC uChange); /// Allows the common dialog box to filter objects that the view displays. /// A pointer to the view's IShellView interface. /// A PIDL, relative to the folder, that identifies the object. /// The browser should return S_OK to include the object in the view, or S_FALSE to hide it. [PreserveSig] new HRESULT IncludeObject([In] IShellView ppshv, PIDL pidl); /// Called by a Shell view to notify the common dialog box hosting it that an event has occurred. /// A pointer to the view's IShellView interface. /// A flag that can can take one of the following two values. void Notify([In] IShellView ppshv, CDB2N dwNotifyType); /// Called by the Shell view to get the default shortcut menu text. /// A pointer to the view's IShellView interface. /// A pointer to a buffer that is used by the Shell browser to return the default shortcut menu text. /// /// The size of the pszText buffer, in characters. It should be at least the maximum allowable path length (MAX_PATH) in size. /// /// /// Returns S_OK if a new default shortcut menu text was returned in pshv. If S_FALSE is returned, use the normal default text. /// Otherwise, returns a standard COM error value. /// [PreserveSig] HRESULT GetDefaultMenuText([In] IShellView ppshv, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszText, int cchMax); /// Called when the view must determine if special customization needs to be made for the common dialog browser. /// A DWORD value that controls the behavior of the view when in common dialog mode. CDB2GVF GetViewFlags(); } /// Extends the capabilities of ICommDlgBrowser2, and used by the common file dialog boxes when they host a Shell browser. /// [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("c8ad25a1-3294-41ee-8165-71174bd01c57")] [PInvokeData("Shobjidl.h", MSDNShortId = "c9286061-8ac8-452b-9204-193bc6b571cb")] public interface ICommDlgBrowser3 : ICommDlgBrowser2 { /// Called when a user double-clicks in the view or presses the ENTER key. /// A pointer to the view's IShellView interface. new void OnDefaultCommand([In] IShellView ppshv); /// Called after a state, identified by the uChange parameter, has changed in the IShellView interface. /// A pointer to the view's IShellView interface. /// Change in the selection state. This parameter can be one of the following values. new void OnStateChange([In] IShellView ppshv, CDBOSC uChange); /// Allows the common dialog box to filter objects that the view displays. /// A pointer to the view's IShellView interface. /// A PIDL, relative to the folder, that identifies the object. /// The browser should return S_OK to include the object in the view, or S_FALSE to hide it. [PreserveSig] new HRESULT IncludeObject([In] IShellView ppshv, PIDL pidl); /// Called by a Shell view to notify the common dialog box hosting it that an event has occurred. /// A pointer to the view's IShellView interface. /// A flag that can can take one of the following two values. new void Notify([In] IShellView ppshv, CDB2N dwNotifyType); /// Called by the Shell view to get the default shortcut menu text. /// A pointer to the view's IShellView interface. /// A pointer to a buffer that is used by the Shell browser to return the default shortcut menu text. /// /// The size of the pszText buffer, in characters. It should be at least the maximum allowable path length (MAX_PATH) in size. /// /// /// Returns S_OK if a new default shortcut menu text was returned in pshv. If S_FALSE is returned, use the normal default text. /// Otherwise, returns a standard COM error value. /// [PreserveSig] new HRESULT GetDefaultMenuText([In] IShellView ppshv, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszText, int cchMax); /// Called when the view must determine if special customization needs to be made for the common dialog browser. /// A DWORD value that controls the behavior of the view when in common dialog mode. new CDB2GVF GetViewFlags(); /// Called after a specified column is clicked in the IShellView interface. /// A pointer to the IShellView interface of the hosted view. /// The index of the column clicked. void OnColumnClicked([In] IShellView ppshv, int iColumn); /// Gets the current filter as a Unicode string. /// Contains a pointer to the current filter path/file as a Unicode string. /// Specifies the path/file length, in characters. void GetCurrentFilter([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFileSpec, int cchFileSpec); /// Called after a specified preview is created in the IShellView interface. /// A pointer to the IShellView interface of the hosted view. void OnPreViewCreated([In] IShellView ppshv); } } }