{"id":4608,"date":"2017-08-22T10:30:23","date_gmt":"2017-08-22T02:30:23","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4608"},"modified":"2017-08-22T10:30:23","modified_gmt":"2017-08-22T02:30:23","slug":"%e6%95%99%e7%a8%8b%e8%b0%83%e7%94%a8-tbrowseforfolder-%e7%9a%84%e6%ad%a3%e7%a1%ae%e5%a7%bf%e5%8a%bf","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4608","title":{"rendered":"[\u6559\u7a0b]\u8c03\u7528 TBrowseForFolder \u7684\u6b63\u786e\u59ff\u52bf"},"content":{"rendered":"<p>TBrowseForFolder \u662f Delphi \/ C++ Builder \u4e2d\u81ea\u5e26\u7684\u4e00\u4e2a\u6d4f\u89c8\u76ee\u5f55\u7684\u5bf9\u8bdd\u6846\uff0c\u4f4d\u4e8e\u00a0StdActns \u5355\u5143\uff08\u540e\u671f\u4e3a Vcl.StdActns \u5355\u5143\uff09\uff0c\u4e0d\u5e78\u7684\u662f\uff0c\u8fd9\u4e2a\u52a8\u4f5c\u4ee3\u7801\u5929\u751f\u6b8b\u75be\uff08\u4ece\u8bde\u751f\u5230\u73b0\u5728\u4e00\u76f4\u6ca1\u6539\u8fc7\u8fd9\u4e2a\u95ee\u9898\uff09\uff0c\u8981\u8ba9\u5176\u597d\u7528\uff0c\u6709\u4e24\u79cd\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n<p>\u7b2c\u4e00\u79cd\uff1a\u522e\u9aa8\u7597\u6bd2=&gt;\u4fee\u6539 StdActns \u5355\u5143\u7684\u4ee3\u7801<\/p>\n<ol>\n<li>\u5c06 StdActns \u5355\u5143\u590d\u5236\u5230\u4f60\u5de5\u7a0b\u76ee\u5f55\u4e0b\uff1b<\/li>\n<li>\u6253\u5f00\u8fd9\u4e2a\u5355\u5143\uff0c\u5e76\u5728 TBrowseForFolder.ExecuteTarget \u5b9e\u73b0\u4e2d\uff0c\u627e\u5230\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\uff1a\n<pre class=\"lang:delphi decode:true \">with BrowseInfo do\r\nbegin\r\nhwndOwner := Application.Handle;\r\npidlRoot := RootItemIDList;\r\n....<\/pre>\n<p>\u5c06 hwndOwner \u7684\u503c\u7531\u00a0Application.Handle \u6539\u4e3a\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">if Assigned(Screen.ActiveForm) then\r\n   hwndOwner:=Screen.ActiveForm.Handle\r\nelse\r\n   hwndOwner:=Application.Handle;<\/pre>\n<p>\u7136\u540e\u5206\u522b\u4f7f\u7528 Release\/Debug \u6a21\u5f0f\u7f16\u8bd1\u8fd9\u4e2a\u5355\u5143\u3002<\/li>\n<li>\u590d\u5236 Release\/Debug \u4e24\u79cd\u6a21\u5f0f\u4e0b\u7684\u76f8\u5e94 StdActns \u7684 dcu \u5230 Delphi\/C++ Builder \u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\u5bf9\u5e94\u7684\u4f4d\u7f6e\uff0c\u8986\u76d6\u539f\u6765\u7684 dcu \u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p>\u7b2c\u4e8c\u79cd\uff1a\u6295\u673a\u53d6\u5de7=&gt;\u65e2\u7136\u4f60\u8bbe\u7f6e\u7684 hwndOwner \u662f Application.Handle\uff0c\u90a3\u6211\u5728\u8c03\u7528\u8fd9\u4e2a\u52a8\u4f5c\u524d\uff0c\u5148\u628a Application.Handle \u7a97\u53e3\u7f6e\u524d\u5c31\u597d\u4e86\uff0c\u8fd9\u6837\u5b50\uff0c\u5f39\u51fa\u7684\u6d4f\u89c8\u76ee\u5f55\u5bf9\u8bdd\u6846\u5c31\u4e0d\u4f1a\u8dd1\u5230\u5176\u5b83\u7a97\u53e3\u540e\u9762\u4e86\u3002\u6240\u4ee5\uff0c\u6b64\u65f6\u6b63\u786e\u7684\u59ff\u52bf\u5c31\u6210\u4e86\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">SetForegroundWindow(Application.Handle);\r\nBrowseForFolder.Execute;<\/pre>\n<p>\u6ce8\u610f\u6b64\u65f6\uff0c\u4f60\u5c31\u4e0d\u80fd\u5c06\u52a8\u4f5c\u7ed1\u5b9a\u5230\u4e00\u4e2a\u63a7\u4ef6\u4e0a\u4e86\uff0c\u800c\u8981\u5728\u63a7\u4ef6\u7684 OnClick \u4e00\u7c7b\u7684\u4e8b\u4ef6\u4e2d\uff0c\u624b\u52a8\u8c03\u7528\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u6bd4\u8f83\u4e00\u4e0b\u4e24\u4e2a\u7684\u4f18\u52a3\uff1a<\/p>\n<ul>\n<li>\u7b2c\u4e00\u79cd\u552f\u4e00\u7684\u95ee\u9898\u5c31\u662f\u6bcf\u6b21\u5347\u7ea7 Delphi \u4f60\u90fd\u9700\u8981\u5904\u7406\u4e00\u904d\uff0c\u76f4\u5230\u5b98\u65b9\u4fee\u6539\u8fd9\u4e2a\u95ee\u9898\uff1b<\/li>\n<li>\u7b2c\u4e8c\u79cd\u552f\u4e00\u7684\u95ee\u9898\u662f\u4f60\u8981\u591a\u5199\u4e24\u884c\u4ee3\u7801\uff0c\u4e0d\u9700\u8981\u7ba1 Delphi \u5347\u7ea7\u7684\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u5982\u4f55\u53d6\u820d\uff0c\u5728\u4e8e\u4f60\u800c\u4e0d\u5728\u4e8e\u6211\u3002\u540c\u6837\u7684\u95ee\u9898\uff0c\u5728 FMX \u4e2d\u4f9d\u7136\u5b58\u5728\uff0c\u540c\u6837\u7684\u529e\u6cd5\u89e3\u51b3\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TBrowseForFolder \u662f D [&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":[69,8,603],"tags":[],"class_list":["post-4608","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-603"],"views":3178,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4608","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=4608"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4608\/revisions"}],"predecessor-version":[{"id":4609,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4608\/revisions\/4609"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}