diff --git a/PInvoke/Shell32/ShObjIdl.ICommDlgBrowser.cs b/PInvoke/Shell32/ShObjIdl.ICommDlgBrowser.cs new file mode 100644 index 00000000..ae36faa6 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.ICommDlgBrowser.cs @@ -0,0 +1,200 @@ +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); + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IExplorerBrowser.cs b/PInvoke/Shell32/ShObjIdl.IExplorerBrowser.cs new file mode 100644 index 00000000..333537b8 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IExplorerBrowser.cs @@ -0,0 +1,196 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// These flags are used with IExplorerBrowser::GetOptions and IExplorerBrowser::SetOptions. + [Flags] + [PInvokeData("Shobjidl.h", MSDNShortId = "4e2983bc-cad2-4bcc-8169-57b5274b2142")] + public enum EXPLORER_BROWSER_OPTIONS + { + /// No options. + EBO_NONE = 0x00000000, + + /// Do not navigate further than the initial navigation. + EBO_NAVIGATEONCE = 0x00000001, + + /// + /// Use the following standard panes: Commands Module pane, Navigation pane, Details pane, and Preview pane. An implementer of + /// IExplorerPaneVisibility can modify the components of the Commands Module that are shown. For more information see, + /// IExplorerPaneVisibility::GetPaneState. If EBO_SHOWFRAMES is not set, Explorer browser uses a single view object. + /// + EBO_SHOWFRAMES = 0X00000002, + + /// Always navigate, even if you are attempting to navigate to the current folder. + EBO_ALWAYSNAVIGATE = 0x00000004, + + /// Do not update the travel log. + EBO_NOTRAVELLOG = 0x00000008, + + /// + /// Do not use a wrapper window. This flag is used with legacy clients that need the browser parented directly on themselves. + /// + EBO_NOWRAPPERWINDOW = 0x00000010, + + /// Show WebView for sharepoint sites. + EBO_HTMLSHAREPOINTVIEW = 0x00000020, + + /// Introduced in Windows Vista. Do not draw a border around the browser window. + EBO_NOBORDER = 0x00000040, + + /// Introduced in Windows Vista. Do not persist the view state. + EBO_NOPERSISTVIEWSTATE = 0x00000080, + } + + /// These flags are used with IExplorerBrowser::FillFromObject. + [Flags] + [PInvokeData("Shobjidl.h", MSDNShortId = "5be62600-147d-4625-8e6c-aa6687da2168")] + public enum EXPLORER_BROWSER_FILL_FLAGS + { + /// No flags. + EBF_NONE = 0x0000000, + + /// + /// Causes IExplorerBrowser::FillFromObject to first populate the results folder with the contents of the parent folders of the + /// items in the data object, and then select only the items that are in the data object. + /// + EBF_SELECTFROMDATAOBJECT = 0x0000100, + + /// + /// Do not allow dropping on the folder. In other words, do not register a drop target for the view. Applications can then + /// register their own drop targets. + /// + EBF_NODROPTARGET = 0x0000200, + } + + /// + /// IExplorerBrowser is a browser object that can be either navigated or that can host a view of a data object. As a full-featured + /// browser object, it also supports an automatic travel log. + /// + /// The Shell provides a default implementation of IExplorerBrowser as CLSID_ExplorerBrowser.Typically, a developer does not need to + /// provide a custom implementation of this interface. + /// + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("dfd3b6b5-c10c-4be9-85f6-a66969f402f6"), CoClass(typeof(ExplorerBrowser))] + [PInvokeData("Shobjidl.h", MSDNShortId = "da2cf5d4-5a68-4d18-807b-b9d4e2712c10")] + public interface IExplorerBrowser + { + /// Prepares the browser to be navigated. + /// A handle to the owner window or control. + /// + /// A pointer to a RECT that contains the coordinates of the bounding rectangle that the browser will occupy. The coordinates are + /// relative to hwndParent. + /// + /// A pointer to a FOLDERSETTINGS structure that determines how the folder will be displayed in the view. + void Initialize([In] HandleRef hwndParent, [In, MarshalAs(UnmanagedType.LPStruct)] RECT prc, [In, MarshalAs(UnmanagedType.LPStruct)] FOLDERSETTINGS pfs); + + /// Destroys the browser. + void Destroy(); + + /// Sets the size and position of the view windows created by the browser. + /// A pointer to a DeferWindowPos handle. This parameter can be NULL. + /// The coordinates that the browser will occupy. + void SetRect(IntPtr phdwp, RECT rcBrowser); + + /// Sets the name of the property bag. + /// + /// A pointer to a constant, null-terminated, Unicode string that contains the name of the property bag. View state information + /// that is specific to the application of the client is stored (persisted) using this name. + /// + void SetPropertyBag([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropertyBag); + + /// Sets the default empty text. + /// A pointer to a constant, null-terminated, Unicode string that contains the empty text. + void SetEmptyText([In, MarshalAs(UnmanagedType.LPWStr)] string pszEmptyText); + + /// Sets the folder settings for the current view. + /// A pointer to a FOLDERSETTINGS structure that contains the folder settings to be applied. + void SetFolderSettings([In, MarshalAs(UnmanagedType.LPStruct)] FOLDERSETTINGS pfs); + + /// Initiates a connection with IExplorerBrowser for event callbacks. + /// A pointer to the IExplorerBrowserEvents interface of the object to be advised of IExplorerBrowser events. + /// + /// When this method returns, contains a token that uniquely identifies the event listener. This allows several event listeners + /// to be subscribed at a time. + /// + void Advise([In] IExplorerBrowserEvents psbe, out uint pdwCookie); + + /// Terminates an advisory connection. + /// + /// A connection token previously returned from IExplorerBrowser::Advise. Identifies the connection to be terminated. + /// + void Unadvise([In] uint dwCookie); + + /// Sets the current browser options. + /// One or more EXPLORER_BROWSER_OPTIONS flags to be set. + void SetOptions([In] EXPLORER_BROWSER_OPTIONS dwFlag); + + /// Gets the current browser options. + /// When this method returns, contains the current EXPLORER_BROWSER_OPTIONS for the browser. + EXPLORER_BROWSER_OPTIONS GetOptions(); + + /// Browses to a pointer to an item identifier list (PIDL) + /// + /// A pointer to a const ITEMIDLIST (item identifier list) that specifies an object's location as the destination to navigate to. + /// This parameter can be NULL. For more information, see Remarks. + /// + /// A flag that specifies the category of the pidl. This affects how navigation is accomplished. + void BrowseToIDList([In] PIDL pidl, [In] SBSP uFlags); + + /// Browses to an object. + /// A pointer to an object to browse to. If the object cannot be browsed, an error value is returned. + /// A flag that specifies the category of the pidl. This affects how navigation is accomplished. + void BrowseToObject([In, MarshalAs(UnmanagedType.IUnknown)] object punk, [In] SBSP uFlags); + + /// Creates a results folder and fills it with items. + /// + /// An interface pointer on the source object that will fill the IResultsFolder. This can be an IDataObject or any object that + /// can be used with INamespaceWalk. + /// + /// One of the EXPLORER_BROWSER_FILL_FLAGS values. + void FillFromObject([In, MarshalAs(UnmanagedType.IUnknown)] object punk, [In] EXPLORER_BROWSER_FILL_FLAGS dwFlags); + + /// Removes all items from the results folder. + void RemoveAll(); + + /// Gets an interface for the current view of the browser. + /// A reference to the desired interface ID. + /// + /// When this method returns, contains the interface pointer requested in riid. This will typically be IShellView, IShellView2, + /// IFolderView, or a related interface. + /// + [return: MarshalAs(UnmanagedType.IUnknown)] + object GetCurrentView([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + } + + /// Exposes methods for notification of Explorer browser navigation and view creation events. + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("361bbdc7-e6ee-4e13-be58-58e2240c810f"), CoClass(typeof(ExplorerBrowser))] + [PInvokeData("Shobjidl.h", MSDNShortId = "802d547f-41c2-4c4a-9f07-be615d7b86eb")] + public interface IExplorerBrowserEvents + { + /// Notifies clients of a pending Explorer browser navigation to a Shell folder. + /// A PIDL that specifies the folder. + void OnNavigationPending([In] PIDL pidlFolder); + + /// Notifies clients that the view of the Explorer browser has been created and can be modified. + /// A pointer to an IShellView. + void OnViewCreated([In] IShellView psv); + + /// Notifies clients that the Explorer browser has successfully navigated to a Shell folder. + /// A PIDL that specifies the folder. + void OnNavigationComplete([In] PIDL pidlFolder); + + /// Notifies clients that the Explorer browser has failed to navigate to a Shell folder. + /// A PIDL that specifies the folder. + void OnNavigationFailed([In] PIDL pidlFolder); + } + + + /// The ExplorerBrowser class is the base CoClass for all I ExplorerBrowser interfaces. + [ComImport, Guid("71f96385-ddd6-48d3-a0c1-ae06e8b055fb"), ClassInterface(ClassInterfaceType.None)] + [PInvokeData("Shobjidl.h", MSDNShortId = "da2cf5d4-5a68-4d18-807b-b9d4e2712c10")] + public class ExplorerBrowser { } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IExplorerPaneVisibility.cs b/PInvoke/Shell32/ShObjIdl.IExplorerPaneVisibility.cs new file mode 100644 index 00000000..d1cce13e --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IExplorerPaneVisibility.cs @@ -0,0 +1,101 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// + /// Indicate flags used by IExplorerPaneVisibility::GetPaneState to get the current state of the given Windows Explorer pane. + /// + [Flags] + [PInvokeData("Shobjidl.h", MSDNShortId = "4caa2fe7-5bb3-4940-a429-fd32128eea84")] + public enum EXPLORERPANESTATE + { + /// Do not make any modifications to the pane. + EPS_DONTCARE = 0x0000, + + /// Set the default state of the pane to "on", but respect any user-modified persisted state. + EPS_DEFAULT_ON = 0x0001, + + /// Set the default state of the pane to "off". + EPS_DEFAULT_OFF = 0x0002, + + /// Unused. + EPS_STATEMASK = 0xFFFF, + + /// Ignore any persisted state from the user, but the user can still modify the state. + EPS_INITIALSTATE = 0x00010000, + + /// + /// Users cannot modify the state, that is, they do not have the ability to show or hide the given pane. This option implies EPS_INITIALSTATE. + /// + EPS_FORCE = 0x00020000, + } + + /// + /// Used in Windows Explorer by an IShellFolder implementation to give suggestions to the view about what panes are visible. + /// Additionally, an IExplorerBrowser host can use this interface to provide information about pane visibility. The host should + /// implement QueryService with SID_ExplorerPaneVisibility as the service ID. The host must be in the site chain. + /// + /// The IExplorerPaneVisibility implementation is retrieved from the Shell folder.The Shell folder, in turn, is retrieved from the + /// view.A namespace extension can elect to provide a custom view(IShellView) rather than using the system folder view object + /// (DefView). In that case, the IShellView implementation must include an implementation of IFolderView::GetFolder to return the + /// IExplorerPaneVisibility object. + /// + /// + /// A namespace extension can provide a custom view by implementing IShellView itself rather than using the system folder view object + /// (DefView). In that case, the IShellView implementation must include an implementation of IFolderView::GetFolder to make use of IExplorerPaneVisibility. + /// + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("e07010ec-bc17-44c0-97b0-46c7c95b9edc")] + [PInvokeData("Shobjidl.h", MSDNShortId = "b940adc2-dfef-49c5-b86c-d0da83db0aad")] + public interface IExplorerPaneVisibility + { + /// Gets the visibility state of the given Windows Explorer pane. + /// + /// A reference to a GUID that uniquely identifies a Windows Explorer pane. One of the constants as defined in Shlguid.h. + /// + /// + /// When this method returns, contains the visibility state of the given Windows Explorer pane as one of the EXPLORERPANESTATE constants. + /// + EXPLORERPANESTATE GetPaneState([In, MarshalAs(UnmanagedType.LPStruct)] Guid ep); + } + + /// Constant GUIDs used by IExplorerPaneVisibility::GetPaneState. + public static class IExplorerPaneVisibilityConstants + { + /// Additional fields and options to aid in a search. + public readonly static Guid EP_AdvQueryPane = new Guid("{b4e9db8b-34ba-4c39-b5cc-16a1bd2c411c}"); + + /// Commands module along the top of the Windows Explorer window. + public readonly static Guid EP_Commands = new Guid("{d9745868-ca5f-4a76-91cd-f5a129fbb076}"); + + /// Organize menu within the commands module. + public readonly static Guid EP_Commands_Organize = new Guid("{72e81700-e3ec-4660-bf24-3c3b7b648806}"); + + /// View menu within the commands module. + public readonly static Guid EP_Commands_View = new Guid("{21f7c32d-eeaa-439b-bb51-37b96fd6a943}"); + + /// Pane showing metadata along the bottom of the Windows Explorer window. + public readonly static Guid EP_DetailsPane = new Guid("{43abf98b-89b8-472d-b9ce-e69b8229f019}"); + + /// The pane on the left side of the Windows Explorer window that hosts the folders tree and Favorites. + public readonly static Guid EP_NavPane = new Guid("{cb316b22-25f7-42b8-8a09-540d23a43c2f}"); + + /// Pane on the right of the Windows Explorer window that shows a large reading preview of the file. + public readonly static Guid EP_PreviewPane = new Guid("{893c63d1-45c8-4d17-be19-223be71be365}"); + + /// Quick filter buttons to aid in a search. + public readonly static Guid EP_QueryPane = new Guid("{65bcde4f-4f07-4f27-83a7-1afca4df7ddd}"); + + /// + /// Introduced in Windows 8: The ribbon, which is the control that replaced menus and toolbars at the top of many Microsoft applications. + /// + public readonly static Guid EP_Ribbon = new Guid("{D27524A8-C9F2-4834-A106-DF8889FD4F37}"); + + /// Introduced in Windows 8: A status bar that indicates the progress of some process, such as copying or downloading. + public readonly static Guid EP_StatusBar = new Guid("{65fe56ce-5cfe-4bc4-ad8a-7ae3fe7e8f7c}"); + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IPreviewHandler.cs b/PInvoke/Shell32/ShObjIdl.IPreviewHandler.cs new file mode 100644 index 00000000..2ddc88a7 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IPreviewHandler.cs @@ -0,0 +1,111 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Exposes methods for the display of rich previews. + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("8895b1c6-b41f-4c1c-a562-0d564250836f")] + [PInvokeData("Shobjidl.h")] + public interface IPreviewHandler + { + /// + /// Sets the parent window of the previewer window, as well as the area within the parent to be used for the previewer window. + /// + /// A handle to the parent window. + /// A pointer to a RECT defining the area for the previewer. + void SetWindow([In] HandleRef hwnd, [In, MarshalAs(UnmanagedType.LPStruct)] RECT prc); + + /// Directs the preview handler to change the area within the parent hwnd that it draws into. + /// A pointer to a RECT to be used for the preview. + void SetRect([In, MarshalAs(UnmanagedType.LPStruct)] RECT prc); + + /// + /// Directs the preview handler to load data from the source specified in an earlier Initialize method call, and to begin + /// rendering to the previewer window. + /// + void DoPreview(); + + /// + /// Directs the preview handler to cease rendering a preview and to release all resources that have been allocated based on the + /// item passed in during the initialization. + /// + void Unload(); + + /// Directs the preview handler to set focus to itself. + void SetFocus(); + + /// Directs the preview handler to return the HWND from calling the GetFocus Function. + /// + /// When this method returns, contains a pointer to the HWND returned from calling the GetFocus Function from the preview + /// handler's foreground thread. + /// + IntPtr QueryFocus(); + + /// + /// Directs the preview handler to handle a keystroke passed up from the message pump of the process in which the preview handler + /// is running. + /// + /// A pointer to a window message. + /// + /// If the keyboard shortcut is one that the host intends to handle, the host will process it and return S_OK; otherwise, it + /// returns S_FALSE. + /// + [PreserveSig] + HRESULT TranslateAccelerator([In, MarshalAs(UnmanagedType.LPStruct)] MSG pmsg); + } + + /// + /// Enables preview handlers to pass keyboard shortcuts to the host. This interface retrieves a list of keyboard shortcuts and + /// directs the host to handle a keyboard shortcut. + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("fec87aaf-35f9-447a-adb7-20234491401a")] + [PInvokeData("Shobjidl.h")] + public interface IPreviewHandlerFrame + { + /// Gets a list of the keyboard shortcuts for the preview host. + /// A pointer to a PREVIEWHANDLERFRAMEINFO structure that receives accelerator table information. + PREVIEWHANDLERFRAMEINFO GetWindowContext(); + + /// Directs the host to handle an keyboard shortcut passed from the preview handler. + /// A pointer to a WM_COMMAND or WM_SYSCOMMAND window message that corresponds to a keyboard shortcut. + /// + /// If the keyboard shortcut is one that the host intends to handle, the host will process it and return S_OK; otherwise, it + /// returns S_FALSE. + /// + [PreserveSig] + HRESULT TranslateAccelerator([In, MarshalAs(UnmanagedType.LPStruct)] MSG pmsg); + } + + /// Exposes methods for applying color and font information to preview handlers. + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("196bf9a5-b346-4ef0-aa1e-5dcdb76768b1")] + [PInvokeData("Shobjidl.h")] + public interface IPreviewHandlerVisuals + { + /// Sets the background color of the preview handler. + /// A value of type COLORREF to use for the preview handler background. + void SetBackgroundColor(COLORREF color); + + /// Sets the font attributes to be used for text within the preview handler. + /// A pointer to a LOGFONTW Structure containing the necessary attributes for the font to use. + void SetFont([In, MarshalAs(UnmanagedType.LPStruct)] LOGFONT plf); + + /// Sets the color of the text within the preview handler. + /// A value of type COLORREF to use for the preview handler text color. + void SetTextColor(COLORREF color); + } + + /// Accelerator table structure. Used by IPreviewHandlerFrame::GetWindowContext. + [StructLayout(LayoutKind.Sequential)] + [PInvokeData("Shobjidl.h")] + public struct PREVIEWHANDLERFRAMEINFO + { + /// A handle to the accelerator table. + public IntPtr haccel; + + /// The number of entries in the accelerator table. + public uint cAccelEntries; + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IServiceProvider.cs b/PInvoke/Shell32/ShObjIdl.IServiceProvider.cs new file mode 100644 index 00000000..67d2d7f4 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IServiceProvider.cs @@ -0,0 +1,21 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Defines a mechanism for retrieving a service object; that is, an object that provides custom support to other objects. + [ComImport, Guid("6d5140c1-7436-11ce-8034-00aa006009fa"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("servprov.h")] + public interface IServiceProvider + { + /// Performs as a factory for services that are exposed through an implementation of IServiceProvider. + /// A unique identifier of the requested service. + /// A unique identifier of the interface which the caller wishes to receive for the service. + /// The interface specified by the riid parameter. + [return: MarshalAs(UnmanagedType.IUnknown)] + object QueryService([In, MarshalAs(UnmanagedType.LPStruct)] Guid guidService, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + }; + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.cs b/PInvoke/Shell32/ShObjIdl.cs index f96d73aa..aea237cf 100644 --- a/PInvoke/Shell32/ShObjIdl.cs +++ b/PInvoke/Shell32/ShObjIdl.cs @@ -408,6 +408,43 @@ namespace Vanara.PInvoke SafeCoTaskMemString GetProgID(); } + /// + /// Provides a simple way to support communication between an object and its site in the container. + /// + /// Often an object needs to communicate directly with a container site object and, in effect, manage the site object itself.Outside + /// of IOleObject::SetClientSite, there is no generic means through which an object becomes aware of its site. IObjectWithSite + /// provides simple objects with a simple siting mechanism (lighter than IOleObject) This interface should only be used when + /// IOleObject is not already in use. + /// + /// + /// Through IObjectWithSite, a container can pass the IUnknown pointer of its site to the object through + /// IObjectWithSite::SetSite.Callers can also retrieve the latest site passed to SetSite through IObjectWithSite::GetSite.This latter + /// method is included as a hooking mechanism, allowing a third party to intercept calls from the object to the site. + /// + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352")] + [PInvokeData("ocidl.h")] + public interface IObjectWithSite + { + /// Enables a container to pass an object a pointer to the interface for its site. + /// + /// A pointer to the IUnknown interface pointer of the site managing this object. If NULL, the object should call Release on any + /// existing site at which point the object no longer knows its site. + /// + void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite); + /// Retrieves the latest site passed using SetSite. + /// The IID of the interface pointer that should be returned in ppvSite. + /// + /// Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvSite contains + /// the requested interface pointer to the site last seen in SetSite. The specific interface returned depends on the riid + /// argument in essence, the two arguments act identically to those in QueryInterface. If the appropriate interface pointer is + /// available, the object must call AddRef on that pointer before returning successfully. If no site is available, or the + /// requested interface is not supported, this method must *ppvSite to NULL and return a failure code. + /// + [return: MarshalAs(UnmanagedType.IUnknown)] + object GetSite([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + } + /// /// Exposes methods that the Shell uses to retrieve flags and info tip information for an item that resides in an IShellFolder implementation. Info tips /// are usually displayed inside a tooltip control.