From 22afda95cfe5ea5cdf3b0e116dbeb2cbf508b6b2 Mon Sep 17 00:00:00 2001 From: dahall Date: Wed, 21 Jul 2021 17:13:01 -0600 Subject: [PATCH] Switched ShellBrowser event handler based methods to overrides and reformatted doc. --- Windows.Shell/ShellObjects/ShellBrowser.cs | 76 +++++++++++++++--------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Windows.Shell/ShellObjects/ShellBrowser.cs b/Windows.Shell/ShellObjects/ShellBrowser.cs index 7d4c4475..49594aa0 100644 --- a/Windows.Shell/ShellObjects/ShellBrowser.cs +++ b/Windows.Shell/ShellObjects/ShellBrowser.cs @@ -108,8 +108,8 @@ namespace Vanara.Windows.Shell } /// - /// Encapsulates a -Implementation within an .

Implements the - /// following Interfaces:
+ /// Encapsulates a -Implementation within an .

Implements the following + /// Interfaces:
/// -
/// -
/// -

For more Information on used techniques see:
@@ -126,7 +126,7 @@ namespace Vanara.Windows.Shell /// - DONE: Disable header in Details view when grouping is enabled /// - DONE: Creating ViewWindow using '.CreateViewWindow()' fails on Zip-Folders; => Fixed again by returning HRESULT.E_NOTIMPL from MessageSFVCB /// - TODO: internal static readonly bool IsMinVista = Environment.OSVersion.Version.Major >= 6; // TODO: We use one interface, - /// afaik, that only works in vista and above: IFolderView2 + /// afaik, that only works in vista and above: IFolderView2 /// - TODO: Windows 10' Quick Access folder has a special type of grouping, can't find out how this works yet. As soon as we would be /// able to get all the available properties for an particular item, we would be able found out how this grouping works. However, it /// seems to be a special group, since folders are Tiles, whereas files are shown in Details mode. @@ -175,9 +175,6 @@ namespace Vanara.Windows.Shell History = new ShellNavigationHistory(); Items = new ShellItemCollection(this, SVGIO.SVGIO_ALLVIEW); SelectedItems = new ShellItemCollection(this, SVGIO.SVGIO_SELECTION); - - Resize += ShellBrowser_Resize; - HandleDestroyed += ShellBrowser_HandleDestroyed; } /// Fires when the Items collection changes. @@ -192,15 +189,6 @@ namespace Vanara.Windows.Shell [Category("Behavior"), Description("Selection changed.")] public event EventHandler SelectionChanged; - /// - ///

- /// Note: I've tried using ComCtl32.ListViewMessage.LVM_SETBKIMAGE, but this doesn't work properly. That's why this property has - /// been hidden. - ///
- [Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public override Image BackgroundImage => base.BackgroundImage; - /// The default text that is displayed when an empty folder is shown [Category("Appearance"), DefaultValue("This folder is empty."), Description("The default text that is displayed when an empty folder is shown.")] public string EmptyFolderText @@ -261,6 +249,15 @@ namespace Vanara.Windows.Shell public string ViewStateRegistryKey { get; set; } = $"Software\\{ Application.CompanyName }\\{ Application.ProductName }\\ShellBrowser\\ViewStateStreams"; + /// + ///

+ /// Note: I've tried using ComCtl32.ListViewMessage.LVM_SETBKIMAGE, but this doesn't work properly. That's why this property has + /// been hidden. + ///
+ [Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public override Image BackgroundImage => base.BackgroundImage; + /// protected override Size DefaultSize => new(200, 150); @@ -582,18 +579,6 @@ namespace Vanara.Windows.Shell /// Raises the event. protected internal virtual void OnSelectionChanged() => SelectionChanged?.Invoke(this, EventArgs.Empty); - /// - /// 's event handler for event: Save ViewState when - /// ShellBrowser gets closed. - /// - protected internal virtual void ShellBrowser_HandleDestroyed(object sender, EventArgs e) => ViewHandler.GetValidInstance()?.ShellView.SaveViewState(); - - /// - /// 's event handler for event: Resize ViewWindow when ShellBrowser - /// gets resized. - /// - protected internal virtual void ShellBrowser_Resize(object sender, EventArgs e) => ViewHandler?.MoveWindow(0, 0, ClientRectangle.Width, ClientRectangle.Height, false); - /// Clean up any resources being used. /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) @@ -605,6 +590,22 @@ namespace Vanara.Windows.Shell base.Dispose(disposing); } + /// Raises the event. Saves ViewState when ShellBrowser gets closed. + /// The instance containing the event data. + protected override void OnHandleDestroyed(EventArgs e) + { + ViewHandler.GetValidInstance()?.ShellView.SaveViewState(); + base.OnHandleDestroyed(e); + } + + /// Raises the event. Resize ViewWindow when ShellBrowser gets resized. + /// The instance containing the event data. + protected override void OnResize(EventArgs e) + { + ViewHandler?.MoveWindow(0, 0, ClientRectangle.Width, ClientRectangle.Height, false); + base.OnResize(e); + } + /// Process known command keys of the ShellBrowser. /// Windows Message /// Key codes and modifiers @@ -785,26 +786,25 @@ namespace Vanara.Windows.Shell } /// - /// Encapsulates an IShellFolderViewCB-Implementation within an -Object. Beside that it's implemented as a Wrapper-Object that is responsible for creating and disposing the - /// following objects aka Interface-Instances:
+ /// Encapsulates an IShellFolderViewCB-Implementation within an -Object. + /// Beside that it's implemented as a Wrapper-Object that is responsible for creating and disposing the following objects aka + /// Interface-Instances:
/// -
/// -
/// -

While doing that, it also handles some common error cases:
/// - When there's no disk in a disk drive

Implements the following Interfaces:
- /// -

This class make use of some undocumented Messages - /// in its Callback Handler.

For more Information on these see:
- /// - Google Drive Shell Extension: - /// ShellFolderViewCBHandler.cpp
- /// - ReactOS: IShellFolderViewCB.cpp File Reference - /// , IShellFolderViewCB.cpp + /// -

This class make use of some undocumented Messages in its + /// Callback Handler.

For more Information on these see:
+ /// - Google Drive Shell Extension: ShellFolderViewCBHandler.cpp
+ /// - ReactOS: IShellFolderViewCB.cpp File Reference + /// , IShellFolderViewCB.cpp ///
public class ShellBrowserViewHandler : IShellFolderViewCB { /// /// {"The operation was canceled by the user. (Exception from HRESULT: 0x800704C7)"} - /// is the result of a call to on a Shell Item that targets a removable Disk Drive - /// when currently no Media is present. Let's catch these to use our own error handling for this. + /// is the result of a call to on a Shell Item that targets a removable Disk Drive when + /// currently no Media is present. Let's catch these to use our own error handling for this. /// internal static readonly HRESULT HRESULT_CANCELLED = new(0x800704C7);