{"id":4994,"date":"2022-04-05T05:03:39","date_gmt":"2022-04-04T20:03:39","guid":{"rendered":"https:\/\/okamurax.com\/?p=4994"},"modified":"2022-04-05T08:44:59","modified_gmt":"2022-04-04T23:44:59","slug":"c-%e3%83%9e%e3%82%a6%e3%82%b9%e5%ba%a7%e6%a8%99-%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95%e3%81%ae%e6%af%94%e8%bc%83","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=4994","title":{"rendered":"C# \u30de\u30a6\u30b9\u5ea7\u6a19 \u53d6\u5f97\u65b9\u6cd5\u306e\u6bd4\u8f03"},"content":{"rendered":"<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Drawing;\r\nusing System.Windows.Forms;\r\n\r\nnamespace WindowsFormsApp1\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        \/\/ \u95a2\u6570\u304c\u5b58\u5728\u3059\u308bDLL\u3092\u6307\u5b9a\u3059\u308b\u3002\r\n        [System.Runtime.InteropServices.DllImport(\"user32.dll\")]\r\n        \r\n        \/\/ extern \r\n        \/\/ \u95a2\u6570\u306e\u5b9f\u4f53\u304c\u5916\u90e8\u306b\u3042\u308b\u3053\u3068\u3092\u793a\u3059\u3002\r\n        static extern int GetCursorPos(out LPPOINT lppoint);\r\n\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n            MouseMove += (s, e) =&gt;\r\n            {\r\n                \/\/ \u30b9\u30af\u30ea\u30fc\u30f3\u5ea7\u6a19(Form\u4e0a\u3057\u304b\u62fe\u308f\u306a\u3044)\r\n                label1.Text = \"X \/ Y : \" + Cursor.Position.X.ToString() + \" \/ \" + Cursor.Position.Y.ToString();\r\n\r\n                \/\/ \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5ea7\u6a19\r\n                label2.Text = \"X \/ Y : \" + e.X.ToString() + \" \/ \" + e.Y.ToString();\r\n            };\r\n\r\n            Timer timer = new Timer();\r\n            timer.Interval = 1;\r\n            timer.Tick += (s, e) =&gt;\r\n            {\r\n                \/\/ \u30b9\u30af\u30ea\u30fc\u30f3\u5ea7\u6a19 GetCursorPos()\r\n                var p = new LPPOINT();\r\n                GetCursorPos(out p);\r\n                label3.Text = \"X \/ Y : \" + p.X.ToString() + \" \/ \" + p.Y.ToString();\r\n            };\r\n\r\n            timer.Start();\r\n        }\r\n\r\n        \/\/ StructLayout(LayoutKind.Sequential)\r\n        \/\/ API\/DLL\u3068\u3084\u308a\u3068\u308a\u3059\u308b\u69cb\u9020\u4f53\u306e\u5834\u5408\u3001\u30e1\u30f3\u30d0\u306e\u30e1\u30e2\u30ea\u4e0a\u306e\u4f4d\u7f6e\u3092API\/DLL\u3068\u4e00\u81f4\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\r\n        \/\/ LayoutKind.Sequential\u3068\u6307\u5b9a\u3059\u308b\u3068\u5ba3\u8a00\u901a\u308a\u3068\u306a\u308b\u3002\r\n        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]\r\n        struct LPPOINT\r\n        {\r\n            public int X { get; set; }\r\n            public int Y { get; set; }\r\n\r\n            \/\/ implicit operator xxx\r\n            \/\/ implicit operator\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u30af\u30e9\u30b9\u81ea\u8eab\u304c\r\n            \/\/ xxx\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3055\u308c\u305f\u3068\u304d\u306b\u52d5\u4f5c\u3059\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n            public static implicit operator Point(LPPOINT point)\r\n            {\r\n                return new Point(point.X, point.Y);\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial cl &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=4994\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u30de\u30a6\u30b9\u5ea7\u6a19 \u53d6\u5f97\u65b9\u6cd5\u306e\u6bd4\u8f03&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-4994","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4994"}],"version-history":[{"count":3,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4994\/revisions"}],"predecessor-version":[{"id":4997,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4994\/revisions\/4997"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}