| |

VerySource

 Forgot password?
 Register
Search
View: 980|Reply: 7

How to realize polygon custom control

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-16 10:00:01
| Show all posts |Read mode
For example, how to realize the control of triangle and trapezoid shape, the control is inherited from the pictureBox or label control.
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-16 11:30:01
| Show all posts
In fact, use pictures for screen performance, just calculate the corresponding position of the mouse reasonably
Reply

Use magic Report

0

Threads

16

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-16 17:00:01
| Show all posts
A simpler implementation method:
When you draw the control, you can draw a polygon, and then fill the polygon with a color different from the background color. In fact, the drawn space is still rectangular, but the background color is different from the polygon fill color.
Reply

Use magic Report

0

Threads

16

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-16 17:15:01
| Show all posts
However, it is better to inherit the Control class directly.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-12-16 19:30:02
| Show all posts
I am now like this: there is a background picture on the form, and a picture is drawn on a Label (occupying the entire Label), but I want to display a small area in the upper right corner as transparent so that it can see the background picture.
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-16 22:15:01
| Show all posts
Create a Region you want, and then assign the label's region attribute
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Brazil

 Author| Post time: 2020-12-17 09:30:01
| Show all posts
Good way upstairs, try it
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-20 08:15:02
| Show all posts
Override the OnPaint event of the control to draw the Region of the graphics you want
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list