Form窗体实现SizeChange函数:

C# winfrom点击最小化按钮时实现回到桌面的功能

 

private void FormLaboratoryProcessHandMore2_SizeChanged(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)//当窗体的状态是最小化时触发
            {
                //MessageBox.Show("test", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);               

                 //以下三句代码是回到桌面的功能,调用了Windows系统命令
                Type shellType = Type.GetTypeFromProgID("Shell.Application");
                object shellObject = System.Activator.CreateInstance(shellType);
                shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, null, shellObject, null);
            }
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-12-28
  • 2022-12-23
相关资源
相似解决方案