ppc全屏程序

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;

namespace Hello_World
{
    public partial class StartForm : Form
    {
        private Timer timer;
        public StartForm()
        {

            InitializeComponent();
            IntPtr hWnd = API.FindWindow(this.Text);
            if (hWnd != IntPtr.Zero)
            {
                System.Diagnostics.Debug.WriteLine("hWnd ist nicht null");
                this.MaximizeBox = false;
                this.MinimizeBox = false;
                this.Focus();

                SHAPI.SetForegroundWindow(hWnd);
                SHAPI.FullScreen(hWnd);
            }
        }
    }

    public class API
    {
        [DllImport("coredll.dll", EntryPoint = "FindWindow")]
        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);

        public static IntPtr FindWindow(string windowName)
        {
            return FindWindow(null, windowName);
        }
    }

    public class SHAPI
    {
        public const int SHFS_SHOWTASKBAR = 1;
        public const int SHFS_HIDETASKBAR = 2;
        public const int SHFS_SHOWSIPBUTTON = 4;
        public const int SHFS_HIDESIPBUTTON = 8;
        public const int SHFS_SHOWSTARTICON = 16;
        public const int SHFS_HIDESTARTICON = 32;

        [DllImport("aygshell.dll")]
        private extern static bool SHFullScreen(IntPtr hWnd, int dwState);

        public static bool FullScreen(IntPtr hWnd)
        {
             return SHFullScreen(hWnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR);
        }

        [DllImport("coredll.dll")]
        internal static extern int SetForegroundWindow(IntPtr hWnd);
    }

 

下面的代码仅仅隐藏开始菜单但程序退出后会重现

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;

namespace Wm5ppc
{
   public partial class Form1 : Form
   {
      public Form1 ()
      {
         InitializeComponent ();
         this.MinimizeBox = false;
      }
      private void Form1_Activated (object sender, EventArgs e)
      {
         IntPtr hWnd = this.Handle;
         SHAPI.FullScreen (hWnd);
      }
   }

   public class SHAPI
   {
      public const int SHFS_SHOWTASKBAR = 1;
      public const int SHFS_HIDETASKBAR = 2;
      public const int SHFS_SHOWSIPBUTTON = 4;
      public const int SHFS_HIDESIPBUTTON = 8;
      public const int SHFS_SHOWSTARTICON = 16;
      public const int SHFS_HIDESTARTICON = 32;
      [DllImport ("aygshell.dll")]
      private extern static bool SHFullScreen (IntPtr hWnd, int dwState);
     
      public static bool FullScreen (IntPtr hWnd)
      {
         return SHFullScreen (hWnd, SHFS_HIDESTARTICON);
      }
   }
}如果想实现程序完全全屏,可以设置Form的WindowState属性为Maximized,并且移除MainMenu1控件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值