{"id":4941,"date":"2018-08-07T17:43:24","date_gmt":"2018-08-07T09:43:24","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4941"},"modified":"2018-08-07T17:54:56","modified_gmt":"2018-08-07T09:54:56","slug":"%e6%95%99%e7%a8%8bfmx-%e4%b8%8b%e5%b0%86%e5%bd%93%e5%89%8d%e6%8e%a7%e4%bb%b6%e7%9a%84%e7%9b%b8%e5%af%b9%e5%9d%90%e6%a0%87%e8%bd%ac%e6%8d%a2%e4%b8%ba%e5%b1%8f%e5%b9%95%e5%9d%90%e6%a0%87","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4941","title":{"rendered":"[\u6559\u7a0b]FMX \u4e0b\u5c06\u5f53\u524d\u63a7\u4ef6\u7684\u76f8\u5bf9\u5750\u6807\u8f6c\u6362\u4e3a\u5c4f\u5e55\u5750\u6807"},"content":{"rendered":"<p>\u597d\u5427\uff0c\u5728 VCL \u91cc\u7b80\u5355\u7684 ClientToScreen\uff0c\u5230\u4e86 FMX \u5c31\u53d8\u5f97\u4e0d\u662f\u90a3\u4e48\u7b80\u5355\u4e86\u3002\u8fd9\u5c31\u7275\u6d89\u5230\u4e86 FMX \u7684\u5750\u6807\u4f53\u7cfb\uff0c\u54b1\u4eec\u4e0d\u5728\u8fd9\u91cc\u7684\u5c55\u5f00\u8bf4\u660e\uff0c\u4ec5\u63d0\u4f9b\u5b9e\u73b0\u7684\u4ecb\u7ecd\uff1a<\/p>\n<p>1\u3001\u8c03\u7528\u63a7\u4ef6\u7684\u00a0LocalToAbsolute \u5c06\u63a7\u4ef6\u5750\u6807\u8f6c\u6362\u4e3a\u7edd\u5bf9\u5750\u6807\uff0c\u8fd9\u4e2a\u7edd\u5bf9\u5750\u6807\u662f\u76f8\u5bf9\u4e8e Form \u7684\uff0c\u6240\u4ee5\u4e0d\u8981\u4ee5\u4e3a\u5b83\u662f\u5c4f\u5e55\u5750\u6807\uff0c\u8fd9\u662f\u4eba\u5f88\u5bb9\u6613\u770b\u540d\u5b57\u731c\u4e3a\u5c4f\u5e55\u5750\u6807\u3002<\/p>\n<p>2\u3001\u8c03\u7528\u63a7\u4ef6\u573a\u666f\u7684 LocalToScreen \u5c06\u7edd\u5bf9\u5750\u6807\u8f6c\u6362\u4e3a\u5c4f\u5e55\u5750\u6807\u3002<\/p>\n<p>\u6240\u4ee5\uff0cFMX \u7684 LocalToScreen \u4e5f\u5c31\u53d8\u6210\u4e86\uff1a<\/p>\n<blockquote><p>pt:=Control.Scene.LocalToScreen(Control.LocalToAbsolute(pt));<\/p><\/blockquote>\n<p>\u540c\u7406\uff0c\u5c06\u5c4f\u5e55\u5750\u6807\u8f6c\u6362\u4e3a\u63a7\u4ef6\u5750\u6807\u7684\u4ee3\u7801\uff0c\u4e5f\u5c31\u9700\u8981\u9006\u8fc7\u6765\uff0c\u5c31\u4e0d\u518d\u7f00\u8ff0\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u4e3a\u4e86\u65b9\u4fbf\uff0c\u6211\u4eec\u7b80\u5355\u7684 helper \u4e0b\u5427\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">type\r\n  TScreenClientHelper = class helper for TControl\r\n    function ClientToScreen(const pt: TPointF): TPointF;inline;\r\n    function ScreenToClient(const pt: TPointF): TPointF;inline;\r\n  end;\r\n\r\n{ TScreenClientHelper }\r\n\r\nfunction TScreenClientHelper.ClientToScreen(const pt: TPointF): TPointF;\r\nbegin\r\n  Result := Scene.LocalToScreen(LocalToAbsolute(pt));\r\nend;\r\n\r\nfunction TScreenClientHelper.ScreenToClient(const pt: TPointF): TPointF;\r\nbegin\r\n  Result := AbsoluteToLocal(Scene.ScreenToLocal(pt));\r\nend;<\/pre>\n<p>\u7136\u540e\u76f4\u63a5\u8c03\u7528 ClientToScreen\/ScreenToClient \u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u5427\uff0c\u5728 VCL \u91cc\u7b80\u5355\u7684 Client [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","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":[69,8],"tags":[754,149],"class_list":["post-4941","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","tag-clienttoscreen","tag-fmx"],"views":4565,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4941","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=4941"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4941\/revisions"}],"predecessor-version":[{"id":4945,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4941\/revisions\/4945"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}