zoukankan      html  css  js  c++  java
  • ppc全屏程序(转)

      1using System;
      2using System.Collections.Generic;
      3using System.ComponentModel;
      4using System.Windows.Forms;
      5using System.Runtime.InteropServices;
      6using System.Text;
      7
      8namespace Hello_World
      9{
     10    public partial class StartForm : Form
     11    {
     12        private Timer timer;
     13        public StartForm()
     14        {
     15
     16            InitializeComponent();
     17            IntPtr hWnd = API.FindWindow(this.Text);
     18            if (hWnd != IntPtr.Zero)
     19            {
     20                System.Diagnostics.Debug.WriteLine("hWnd ist nicht null");
     21                this.MaximizeBox = false;
     22                this.MinimizeBox = false;
     23                this.Focus();
     24
     25                SHAPI.SetForegroundWindow(hWnd);
     26                SHAPI.FullScreen(hWnd);
     27            }

     28        }

     29    }

     30
     31    public class API
     32    {
     33        [DllImport("coredll.dll", EntryPoint = "FindWindow")]
     34        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
     35
     36        public static IntPtr FindWindow(string windowName)
     37        {
     38            return FindWindow(null, windowName);
     39        }

     40    }

     41
     42    public class SHAPI
     43    {
     44        public const int SHFS_SHOWTASKBAR = 1;
     45        public const int SHFS_HIDETASKBAR = 2;
     46        public const int SHFS_SHOWSIPBUTTON = 4;
     47        public const int SHFS_HIDESIPBUTTON = 8;
     48        public const int SHFS_SHOWSTARTICON = 16;
     49        public const int SHFS_HIDESTARTICON = 32;
     50
     51        [DllImport("aygshell.dll")]
     52        private extern static bool SHFullScreen(IntPtr hWnd, int dwState);
     53
     54        public static bool FullScreen(IntPtr hWnd)
     55        {
     56             return SHFullScreen(hWnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR);
     57        }

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

     62}
     
     63 
     64
     65下面的代码仅仅隐藏开始菜单但程序退出后会重现
     66
     67using System;
     68using System.Collections.Generic;
     69using System.ComponentModel;
     70using System.Windows.Forms;
     71using System.Runtime.InteropServices;
     72using System.Text;
     73
     74namespace Wm5ppc
     75{
     76   public partial class Form1 : Form
     77   {
     78      public Form1 ()
     79      {
     80         InitializeComponent ();
     81         this.MinimizeBox = false;
     82      }

     83      private void Form1_Activated (object sender, EventArgs e)
     84      {
     85         IntPtr hWnd = this.Handle;
     86         SHAPI.FullScreen (hWnd);
     87      }

     88   }

     89
     90   public class SHAPI
     91   {
     92      public const int SHFS_SHOWTASKBAR = 1;
     93      public const int SHFS_HIDETASKBAR = 2;
     94      public const int SHFS_SHOWSIPBUTTON = 4;
     95      public const int SHFS_HIDESIPBUTTON = 8;
     96      public const int SHFS_SHOWSTARTICON = 16;
     97      public const int SHFS_HIDESTARTICON = 32;
     98      [DllImport ("aygshell.dll")]
     99      private extern static bool SHFullScreen (IntPtr hWnd, int dwState);
    100      
    101      public static bool FullScreen (IntPtr hWnd)
    102      {
    103         return SHFullScreen (hWnd, SHFS_HIDESTARTICON);
    104      }

    105   }

    106}

     如果想实现程序完全全屏,可以设置Form的WindowState属性为Maximized,并且移除MainMenu1控件
    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1570064

  • 相关阅读:
    线程数究竟设多少合理
    Elasticsearch 技术分析(八):剖析 Elasticsearch 的索引原理
    作为程序员你是如何学习的?
    系统运行缓慢,CPU 100%,以及Full GC次数过多问题的排查思路
    kms相关文档
    删除所有docker容器镜像
    ubuntu mysql5.7安装
    GORM自定义日志配置
    SQL清空全部表数据
    Nginx 证书
  • 原文地址:https://www.cnblogs.com/wt0731/p/888476.html
Copyright © 2011-2022 走看看