1.首先要创建一个窗体应用程序,在在此程序添加一个窗体程序
2.初始化时获取屏幕数量信息:
// 获取所有屏幕信息
Screen[] screens = Screen.AllScreens;
if (screens.Length >= 0)
{
// 获取第二个屏幕的信息
int lcd = Convert.ToInt32(INIRead("par1", "screens", strIniPath));//本地可以配置屏幕显示
Screen secondScreen = screens[lcd];//启动屏幕
Form2 form = new Form2();
form.StartPosition = FormStartPosition.Manual;
form.Location = secondScreen.Bounds.Location;
form.WindowState = FormWindowState.Maximized;
form.ShowDialog();
}
2.增加一个线成 切图使用(图片的名称按照阿拉伯数字排列)
public void Picture()//增加一个线成 切换图片使用
{
if (tu ==temp1 )//图片总张数
{
tu = temp;//起始图片名称
}
path = System.AppDomain.CurrentDomain.BaseDirectory + "\\picture" + $"\\{tu}.png";
this.BackgroundImage = Image.FromFile(path);//背景展示的图片
tu = tu + 1;
}
3.创建鼠标事件
private void Form2_MouseDown(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left) // 判断左键是否被点击
{
Thread th = new Thread(Picture);
th.Start();
}
else if (e.Button == MouseButtons.Right)
{
DialogResult re = MessageBox.Show("鼠标右击退出", "提醒!!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (re == DialogResult.OK)
{
// Application.Exit();//所有进程停止 窗户关闭
this.Close();
}
}
4.效果演示: