{"id":4276,"date":"2016-10-17T08:55:15","date_gmt":"2016-10-17T00:55:15","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4276"},"modified":"2016-10-17T08:55:15","modified_gmt":"2016-10-17T00:55:15","slug":"delphi-%e6%af%94%e8%be%83%e4%ba%8b%e4%bb%b6%e5%93%8d%e5%ba%94%e8%80%85%e6%98%af%e5%90%a6%e6%98%af%e7%89%b9%e5%ae%9a%e7%9a%84%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4276","title":{"rendered":"[Delphi] \u6bd4\u8f83\u4e8b\u4ef6\u54cd\u5e94\u8005\u662f\u5426\u662f\u7279\u5b9a\u7684\u51fd\u6570"},"content":{"rendered":"<p>Delphi \u4e2d\u7684\u4e8b\u4ef6\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a TMethod \u7c7b\u578b\u7684\u53cc\u6307\u9488\u7ed3\u6784\u4f53\uff0c\u4f46\u662f Delphi \u5e76\u6ca1\u6709\u63d0\u4f9b\u7b80\u5355\u7684\u5199\u6cd5\uff0c\u5982\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">if OnClick=Button1Click then<\/pre>\n<p>\u8fd9\u4e48\u5199\u770b\u8d77\u6765\u662f\u5b8c\u7f8e\u7684\uff0c\u4f46\u662f\u5374\u662f\u65e0\u6cd5\u7f16\u8bd1\u901a\u8fc7\u7684\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u63d0\u4f9b\u4e00\u4e2a\u989d\u5916\u7684\u6a21\u677f\u7c7b\u6765\u505a\u8fd9\u4e2a\u4e8b\u60c5\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">type\r\n  TEventComparer&lt;T&gt;=class\r\n  public\r\n    class function Equals(M1,M2:T):Boolean;\r\n  end;\r\n{ TEventComparer&lt;T&gt; }\r\n\r\nclass function TEventComparer&lt;T&gt;.Equals(M1, M2: T): Boolean;\r\nvar\r\n  V1:TMethod absolute M1;\r\n  V2:TMethod absolute M2;\r\nbegin\r\nResult:=(V1.Code=V2.Code) and (V1.Data=V2.Data);\r\nend;<\/pre>\n<p>\u7136\u540e\u6211\u4eec\u8981\u6bd4\u8f83\u65f6\uff0c\u53ea\u9700\u5199\u6210 TEventComparer&lt;\u4e8b\u4ef6\u7c7b\u578b&gt;.Equals(\u4e8b\u4ef61\uff0c\u4e8b\u4ef62\uff09\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">if TEventComparer&lt;TNotifyEvent&gt;.Equals(OnClick,Button1Click) then\r\n   ...<\/pre>\n<p>\u597d\u5427\uff0c\u770b\u8d77\u6765\u9ebb\u70e6\u4e86\u4e00\u70b9\uff0c\u5728\u5b98\u65b9\u6539\u8fdb\u7f16\u8bd1\u5668\u4ee5\u652f\u6301\u524d\u9762\u7684\u5199\u6cd5\u4e4b\u524d\uff0c\u8fd9\u7b97\u662f\u4e00\u4e2a\u6298\u4e2d\u5427\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Delphi \u4e2d\u7684\u4e8b\u4ef6\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a TM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8,21],"tags":[333,676],"class_list":["post-4276","post","type-post","status-publish","format-standard","hentry","category-delphi","category-misc","tag-333","tag-676"],"views":3652,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4276"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4276\/revisions"}],"predecessor-version":[{"id":4277,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4276\/revisions\/4277"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}