admin管理员组文章数量:1206196
I'm trying to make a function that has the user drag the program around from a specific spot in the window. I have the drag function coded into the program, but I can't find a way to set where the drag should happen from in the window.
I'm fairly new to coding and I would apricate it if any answers could dumb it down a tad.
Right now I'm trying to make a panel transparent, but still able to interact with the mouse, but adding transparency just makes the panel unable to interact. The panel also cuts out the rest of my window, when I want the panels behind the transparent panel to be visible.
private bool _dragging = false;
private Point _start_point = new Point(0, 0);
private bool veiwSettings = false;
public Form1()
{
InitializeComponent();
this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
this.TopMost = true;
panel1.BackColor = Color.FromArgb(0, 1, 1, 1);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Image = new Bitmap("EverythingElse\\Pictures\\space.png");
groupBox1.Visible = false;
}
private int Count = 0;
List<string> paths = new List<string>
{
"Ash.jfif","Bed.png","space.png"
};
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap("EverythingElse\\Pictures\\" + paths[Count]);
Count++;
if (Count >= paths.Count) Count = 0;
}
private void Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
_dragging = true;
_start_point = new Point(e.X, e.Y);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (_dragging)
{
Point p = PointToScreen(e.Location);
Location = new Point(p.X - this._start_point.X, p.Y - this._start_point.Y);
}
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
_dragging = false;
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
veiwSettings = !veiwSettings;
}
if (veiwSettings == true)
{
groupBox1.Visible = true;
}
else
{
groupBox1.Visible = false;
}
}
Would it be easier to try to continue to make the panel transparent, or would something else work better?
本文标签: winformsHow to make a functioning transparent button in cStack Overflow
版权声明:本文标题:winforms - How to make a functioning transparent button in c# - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738668449a2105846.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论