[Win10] [C# Desktop] Deskband test, can realize the effect of embedding the taskbar in the window of Master Lu

Overview

Presumably everyone is familiar with software like Master Lu, so those who have used it will definitely find a function very useful, that is, a small control displayed in the language bar of the taskbar to monitor the usage of some system resources. There are certainly many people who want to make software like it, but when searching, they can’t even find a keyword. What exactly is this position on the taskbar called? By chance, I found its scientific name- DeskBand .

But what is uncomfortable is that there is very little information about its customization on MSDN, but fortunately, there is no way to go. You can find a ready-made version of CSDeskBand on Github. This person has already packaged the relevant functions to perfection. You can see the effect.

Of course, there is also a reference on the blog garden. I saw this at first, but there will be a strange problem when this case runs. When restarting explorer, the Deskband will automatically hide and need to be selected again. Display:
C# Winform WPF DeskBand form is embedded in the taskbar, and text is displayed on the taskbar

Preview

1709 Windows 4.7 .net framework test available

By relocating the original library, I currently only implement the WPF part, and the effect is as follows.

In fact, the bottom window carrier is Winform, and the WPF control just adds a layer of ElementHost on top to host the WPF control. When the mouse right-clicks on it, a custom menu item will pop up.

achieve

Because there are so many methods in the original library for generating logs, I moved the methods in the original library that are only related to the creation of Deskband and other taskbars. In this way, the entire class library is roughly reduced in size by half.
The problem that still exists is that when the Deskband created by this method is used for the first time, there is a certain chance that it will be hidden after restarting Explorer , unless the taskbar has been activated .
And it cannot be loaded into the GAC, otherwise it will be hidden after restarting on my machine and needs to be selected again.
Generate it first when you use it, and the file structure should be like this after it is generated. Regasm is in tools.

Then the administrator should run bat.


2019 - 1 - 18

Solved the problem that the restart cannot be retained , and the dll can be loaded into the GAC to run. It seems that the return types of several COM imported methods in the previous version are incorrect. Many COMImport functions in the original version have no return value. However, I found another Deskabnd module made by another person on Github: SharpShell (this In the module is very rich), these imported functions have return values, so I guess the reason why they could not be retained before is that these interface functions did not return corresponding results during the process of being called, which caused the system to fail to recognize some parameters. There is no record of the behavior of the deskband (mainly because these cannot be found in the registry, only the class can be searched through GUID, it can be seen that these behavior data may be binary or exist elsewhere).
The current problem is that when using WPF controls, even if you set "IsHitTestVisible="False"", there is no way to generate mouse events in the non-empty area of ​​the Deskband area, that is, the taskbar right-click menu will not pop up.

Project github

Guess you like

Origin blog.csdn.net/q886yes/article/details/86531307
Recommended