﻿{"id":180,"date":"2010-05-25T12:10:53","date_gmt":"2010-05-25T04:10:53","guid":{"rendered":"http:\/\/nick.workao.org\/index.php\/other\/%e5%b5%8c%e5%85%a5%e5%bc%8f\/180"},"modified":"2021-11-17T11:27:03","modified_gmt":"2021-11-17T03:27:03","slug":"ppc-winform-%e7%a8%8b%e5%ba%8f-%e5%a6%82%e4%bd%95-%e5%85%a8%e5%b1%8f%ef%bc%88c%ef%bc%89%ef%bc%88%e8%bd%ac%ef%bc%89","status":"publish","type":"post","link":"https:\/\/nick.txtcc.com\/index.php\/scm\/180","title":{"rendered":"PPC winform \u7a0b\u5e8f \u5982\u4f55 \u5168\u5c4f\uff08C#\uff09\uff08\u8f6c\uff09"},"content":{"rendered":"<pre>using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Windows.Forms;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace Hello_World\n{\n     public partial class StartForm : Form\n     {\n        private Timer timer;\n        public StartForm()\n        {\n\n            InitializeComponent();\n            IntPtr hWnd = API.FindWindow(this.Text);\n            if (hWnd != IntPtr.Zero)\n            {\n                System.Diagnostics.Debug.WriteLine(\"hWnd ist nicht null\");\n                this.MaximizeBox = false;\n                this.MinimizeBox = false;\n                this.Focus();\n\n                SHAPI.SetForegroundWindow(hWnd);\n                SHAPI.FullScreen(hWnd);\n            }\n       }\n    }\n\n   public class API\n    {\n        [DllImport(\"coredll.dll\", EntryPoint = \"FindWindow\")]\n        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);\n\n        public static IntPtr FindWindow(string windowName)\n        {\n            return FindWindow(null, windowName);\n        }\n    }\n\n    public class SHAPI\n    {\n        public const int SHFS_SHOWTASKBAR = 1;\n        public const int SHFS_HIDETASKBAR = 2;\n        public const int SHFS_SHOWSIPBUTTON = 4;\n        public const int SHFS_HIDESIPBUTTON = 8;\n        public const int SHFS_SHOWSTARTICON = 16;\n        public const int SHFS_HIDESTARTICON = 32;\n\n        [DllImport(\"aygshell.dll\")]\n        private extern static bool SHFullScreen(IntPtr hWnd, int dwState);\n\n        public static bool FullScreen(IntPtr hWnd)\n        {\n             return SHFullScreen(hWnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR);\n        }\n\n        [DllImport(\"coredll.dll\")]\n        internal static extern int SetForegroundWindow(IntPtr hWnd);\n   }\n}<\/pre>\n<pre><\/pre>\n<p><span style=\"color: #ff0000;\"><strong>\u4e0b\u9762\u7684\u4ee3\u7801\u4ec5\u4ec5\u9690\u85cf\u5f00\u59cb\u83dc\u5355\u4f46\u7a0b\u5e8f\u9000\u51fa\u540e\u4f1a\u91cd\u73b0\uff1a<\/strong><\/span><\/p>\n<pre>using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Windows.Forms;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace Wm5ppc\n{\n   public partial class Form1 : Form\n   {\n      public Form1 ()\n      {\n         InitializeComponent ();\n         this.MinimizeBox = false;\n      }\n      private void Form1_Activated (object sender, EventArgs e)\n      {\n         IntPtr hWnd = this.Handle;\n         SHAPI.FullScreen (hWnd);\n      }\n   }\n\n   public class SHAPI\n   {\n      public const int SHFS_SHOWTASKBAR = 1;\n      public const int SHFS_HIDETASKBAR = 2;\n      public const int SHFS_SHOWSIPBUTTON = 4;\n      public const int SHFS_HIDESIPBUTTON = 8;\n      public const int SHFS_SHOWSTARTICON = 16;\n      public const int SHFS_HIDESTARTICON = 32;<\/pre>\n<pre>      [DllImport (\"aygshell.dll\")]\n      private extern static bool SHFullScreen (IntPtr hWnd, int dwState);\n\n      public static bool FullScreen (IntPtr hWnd)\n      {\n         return SHFullScreen (hWnd, SHFS_HIDESTARTICON);\n      }\n   }\n}<\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u672c\u4eba\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u597d\u50cf\u4e0d\u662f\u5f88\u7a33\u5b9a\uff0c\u8bd5\u8fc7\u51e0\u6b21\u662f\u53ef\u4ee5\u5168\u5c4f\u7684\uff0c\u8fde\u5f00\u59cb\u83dc\u5355\u4e5f\u6ca1\u6709\u4e86\uff0c\u73b0\u5728\u4e00\u76f4\u90fd\u6ca1\u529e\u6cd5\u5168\u5c4f\uff0c\u6211\u6d4b\u8bd5\u7684\u7cfb\u7edf\u662fWINCE5\uff0c\u4e0d\u77e5\u9053\u662f \u4e0d\u662f\u6f0f\u4e86\u54ea\u4e2a\u6b65\u9aa4\u6ca1\u505a\u597d\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Fo&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[125,126,127],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-scm","tag-ppc","tag-winform","tag-127"],"_links":{"self":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":2219,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions\/2219"}],"wp:attachment":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}