﻿{"id":506,"date":"2009-12-07T04:04:00","date_gmt":"2009-12-06T20:04:00","guid":{"rendered":"http:\/\/blog.jixin.ntxz.net\/?p=506"},"modified":"2010-07-30T15:41:11","modified_gmt":"2010-07-30T07:41:11","slug":"c%e5%ae%9e%e7%8e%b0%e6%97%a0%e6%a0%87%e9%a2%98%e6%a0%8f%e6%8b%96%e5%8a%a8%e7%aa%97%e4%bd%93%e5%9c%b0%e6%96%b9%e6%b3%95%ef%bc%88api%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.ntxz.net\/?p=506","title":{"rendered":"C#\u5b9e\u73b0\u65e0\u6807\u9898\u680f\u62d6\u52a8\u7a97\u4f53\u5730\u65b9\u6cd5\uff08API\uff09"},"content":{"rendered":"<table cellSpacing=0 cellPadding=0>\n<tbody>\n<tr>\n<td class=t_msgfont id=postmessage_800>\u4e00<br \/>\u8c03\u7528API\u6d88\u606f<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[DllImport(&#8220;user32.dll&#8221;)]<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;public extern static long SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;public const int WM_SYSCOMMAND = 0x0112;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[DllImport(&#8220;user32.dll&#8221;)]<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;public extern static bool ReleaseCapture();<br \/>\u9f20\u6807\u4e8b\u4ef6<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; this.Opacity = 0.2;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; ReleaseCapture();<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; SendMessage(this.Handle, WM_SYSCOMMAND, 0xF017, 0);<\/p>\n<p>\u4e8c<br \/>\u8c03\u7528API\u6d88\u606f<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[DllImport(&#8220;user32.dll&#8221;)]<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wparam, int lparam);<br \/>\u91cd\u5199\u7684\u9f20\u6807\u4e8b\u4ef6<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;protected override voidonMouseDown(MouseEventArgs e)<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;base.OnMouseDown(e); if (e.Button == MouseButtons.Left)\/\/\u6309\u4e0b\u7684\u662f\u9f20\u6807\u5de6\u952e&nbsp;&nbsp;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Capture = false;\/\/\u91ca\u653e\u9f20\u6807\uff0c\u4f7f\u80fd\u591f\u624b\u52a8***\u4f5c&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; SendMessage(Handle, 0x00A1, 2, 0);\/\/\u62d6\u52a8\u7a97\u4f53&nbsp; &nbsp;&nbsp;&nbsp;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<\/p>\n<p>\u4e09<br \/>\u516c\u7528\u5b9a\u91cf<br \/>private const int WM_NCHITTEST = 0x84;<br \/>private const int HTCLIENT = 0x1;<br \/>private const int HTCAPTION = 0x2;<\/p>\n<p>\u9f20\u6807\u91cd\u5199<\/p>\n<p>protected override void WndProc(ref Message m)<br \/>{<br \/>&nbsp; &nbsp;&nbsp; &nbsp; switch(m.Msg)<br \/>&nbsp; &nbsp;&nbsp; &nbsp;{<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;case WM_NCHITTEST:<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; base.WndProc(ref m);<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if ((int)m.Result == HTCLIENT)<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;m.Result = (IntPtr)HTCAPTION;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;<br \/>&nbsp; &nbsp; }<br \/>&nbsp; &nbsp; base.WndProc(ref m);<br \/>}<\/p>\n<p>\u56db<br \/>\u91cd\u5199\u9f20\u6807\u4e8b\u4ef6<\/p>\n<p>protected override void WndProc(ref Message m)<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;switch (m.Msg)<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; case 0x0201:\/\/\u9f20\u6807\u5de6\u952e\u6309\u4e0b\u7684\u6d88\u606f<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;m.Msg = 0x00A1;\/\/\u66f4\u6539\u6d88\u606f\u4e3a\u975e\u5ba2\u6237\u533a\u6309\u4e0b\u9f20\u6807<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;m.LParam = IntPtr.Zero;\/\/\u9ed8\u8ba4\u503c<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;m.WParam = new IntPtr(2);\/\/\u9f20\u6807\u653e\u5728\u6807\u9898\u680f\u5185<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;base.WndProc(ref m);<br \/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u8c03\u7528API\u6d88\u606f&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[DllImpor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,8],"tags":[],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-1","category-oldblog"],"views":463,"_links":{"self":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=506"}],"version-history":[{"count":1,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/506\/revisions"}],"predecessor-version":[{"id":815,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/506\/revisions\/815"}],"wp:attachment":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}