The Windows Explorer can display notification banners under certain conditions. They are displayed in the upper area of the shell view, like this for example in the case of a failing network:
As you can see in this screenshot, a banner can also contain a menu the end-user can open and use.
ShellBoost version 1.2.2.0 offers exclusive support for this feature.
To display such a banner, you must override methods of the ShellFolder class. This is demonstrated in the Registry Folder sample.
So, if you just want to display a message, override the GetInformationBar method, like this, for example:
// this is called by ShellBoost protected override InformationBar GetInformationBar() { // in this sample, we test the user has enough rights if (Hive != RegistryHive.LocalMachine || DiagnosticsInformation.GetTokenElevationType() == TokenElevationType.Full) return null; var bar = new InformationBar(); // the guid identifies the banner, it must not be the empty guid. // Use the same guid for one given banner. bar.Guid = _adminMessageGuid; // set the message that will be displayed to the end-user. // it must not be null nor empty not whitespaces only bar.Message = "You must be running with full priviledges to change anything here"; return bar; }
This is what’s displayed when the Shell Folder is open:
In this screenshot, we also added a menu (this is optional) like this:
protected override void CreateInformationBarMenu(InformationBar bar, ShellMenu appendMenu) { var item = new ShellMenuItem(appendMenu, "What is my UAC level?"); appendMenu.Items.Add(item); }
And the menu handling is done like this:
protected override async void HandleInformationBarMenu(InformationBar bar, IntPtr hwndOwner, int id) { if (id == 1) // first item has id 1, etc. { await WindowsUtilities.DoModelessAsync(() => { System.Windows.Forms.MessageBox.Show(new Win32Window(hwndOwner), "UAC level is " + DiagnosticsInformation.GetTokenElevationType(), "Registry Folder"); }); return; } }
Each menu item added to the banner menu is automatically given an id that correspond to it’s insertion index.
The result is shown here:
Note the MessageBox here is a modeless Window for your app (the ShellBoost Shell Folder server) but a modal one for the Explorer Window.