I have two Windows forms in a project: a normal rectangular one called frm1 and a shaped windows form called frm2. In frm1, there is a button named themeBtn which controls the visibility of frm2. Now I want to make frm2 always show itself at the same position(below the themeBtn) of the frm1(frm1 can be moved but it's size is fixed)). How can make it?
Below is the code of the shape for frm2:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
Point point1 = new Point(0, 12);
Point point2 = new Point(133, 12);
Point point3 = new Point(141, 0);
Point point4 = new Point(149, 12);
Point point5 = new Point(282, 12);
Point point6 = new Point(282, 238);
Point point7 = new Point(0, 238);
Point[] curvePoints =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7
};
shape.AddPolygon(curvePoints);
this.Region = new System.Drawing.Region(shape);
}
I tried the following code in vain:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Point p = new Point();
p = Properties.Settings.Default.themeBtnLocation;
System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
Point point1 = new Point(0, p.Y+12);
Point point2 = new Point(p.X-8, p.Y+12);
Point point3 = new Point(p.X, p.Y);
Point point4 = new Point(p.X+8, p.Y+12);
Point point5 = new Point(2*p.X, p.Y+12);
Point point6 = new Point(2*p.X, s.Height);//height of frm2
Point point7 = new Point(0, s.Height);
Point[] curvePoints =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7
};
shape.AddPolygon(curvePoints);
this.Region = new System.Drawing.Region(shape);
}
What I try to make is thmem select in lots of software.See the picture below
When I click the theme button, a new custom shape was showed exactly below the button regardless the main form is moving or not.)