question
Solution
In order to achieve transparency, we created a custom control from the Control class. The interface contains a colorful circle that can display text. The control discloses custom attributes for setting opacity, internal filling (distance between internal rectangles and control boundary) and font filling (distance between text and internal rectangles). In order to make the control transparent, we rewritten the CreateParams method and set its EXSTYLE to WS_EX_TRANSPARENT.
custom style
We use the control.setStyle () method to modify the control behavior by adding ControlStyles:
ControlStyles.opaque:
Prevent Background from drawing background to avoid system management.ControlStyles.supportstransparentbackColor:
complete code
C#custom control complete code has been provided.
Application control To use this control, please create a new class file, paste the provided code to it, and then build a project. The custom control will appear in the toolbox. Drag it to the window and adjust its custom attributes as needed.
As a result, a translucent circular control with text can be located and adjusted without overlapping with other controls.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3