{"id":13246,"date":"2023-04-28T16:03:41","date_gmt":"2023-04-28T08:03:41","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=13246"},"modified":"2023-04-28T16:33:22","modified_gmt":"2023-04-28T08:33:22","slug":"walk","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/04\/28\/walk\/","title":{"rendered":"go\u8bed\u8a00\u4e4bwalk\u5e93\u7528\u6cd5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go \u8bed\u8a00\u7684 walk \u5e93\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7ec4\u7b80\u5355\u800c\u5f3a\u5927\u7684 API\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u8f7b\u677e\u5730\u6784\u5efa\u4e30\u5bcc\u7684 Windows \u754c\u9762\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0e\u5176\u4ed6 GUI \u5e93\u76f8\u6bd4\uff0cwalk \u5e93\u7684\u4e3b\u8981\u7279\u70b9\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6613\u5b66\u6613\u7528\uff1awalk \u5e93\u7684 API \u8bbe\u8ba1\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5feb\u901f\u4e0a\u624b\uff0c\u5e76\u5feb\u901f\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n\n\n\n<li>\u8de8\u5e73\u53f0\u652f\u6301\uff1a\u867d\u7136 walk \u5e93\u7684\u539f\u751f\u5b9e\u73b0\u53ea\u652f\u6301 Windows \u64cd\u4f5c\u7cfb\u7edf\uff0c\u4f46\u5b83\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7c7b\u4f3c\u63a5\u53e3\u7684 cross-platform \u5b9e\u73b0\uff0c\u53ef\u4ee5\u8de8\u5e73\u53f0\u8fd0\u884c<\/li>\n\n\n\n<li>\u9ad8\u6548\u6027\u80fd\uff1awalk \u5e93\u7684\u5e95\u5c42\u4ee3\u7801\u4f7f\u7528\u4e86\u9ad8\u6548\u7684 C++ \u5b9e\u73b0\uff0c\u4fdd\u8bc1\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u9ad8\u6027\u80fd\u548c\u6d41\u7545\u6027\u3002<\/li>\n\n\n\n<li>\u652f\u6301\u591a\u79cd\u754c\u9762\u5143\u7d20\uff1awalk \u5e93\u652f\u6301\u6dfb\u52a0\u591a\u79cd\u5e38\u89c1\u7684\u754c\u9762\u5143\u7d20\uff0c\u5982\u6309\u94ae\u3001\u6587\u672c\u6846\u3001\u6807\u7b7e\u7b49\uff0c\u5e76\u5728\u8fd9\u4e9b\u63a7\u4ef6\u7684\u57fa\u7840\u4e0a\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u4e8b\u4ef6\u5904\u7406\u65b9\u5f0f\u3002<\/li>\n\n\n\n<li>\u8be6\u7ec6\u6587\u6863\u548c\u793a\u4f8b\uff1awalk \u5e93\u6709\u7740\u8be6\u7ec6\u7684\u6587\u6863\u548c\u793a\u4f8b\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u4eba\u5458\u66f4\u5feb\u5730\u5165\u95e8\u5e76\u6df1\u5165\u4e86\u89e3\u5176\u4f7f\u7528\u7ec6\u8282\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">github\u5730\u5740\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;github.com\/lxn\/walk<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e00\u3001\u8fd0\u884c\u4e00\u4e2a\u7b80\u6613\u7a97\u53e3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u901a\u8fc7walk\u8fd0\u884c\u8d77\u6765\u4e00\u4e2a\u7b80\u6613\u7684\u684c\u9762\u7a0b\u5e8f\uff0c\u4e3b\u8981\u9700\u8981\u4ee5\u4e0b\u4e09\u6b65<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e3b\u7a0b\u5e8f\u6587\u4ef6main.go\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\r\n\r\nimport (\r\n\t\"github.com\/lxn\/walk\"\r\n\t. \"github.com\/lxn\/walk\/declarative\"\r\n\t\"strings\"\r\n)\r\n\r\nfunc main() {\r\n\tvar inTE, outTE *walk.TextEdit\r\n\r\n\tMainWindow{\r\n\t\tTitle:   \"\u7b80\u6613\u7a97\u53e3\",        \/\/windows\u4e3b\u7a97\u53e3\u7684\u540d\u5b57\r\n\t\tMinSize: Size{300, 200},   \/\/\u5927\u5c0f\r\n\t\tLayout:  VBox{},\r\n\t\tChildren: &#91;]Widget{\r\n\t\t\tHSplitter{\r\n\t\t\t\tChildren: &#91;]Widget{\r\n\t\t\t\t\tTextEdit{AssignTo: &amp;inTE},\r\n\t\t\t\t\tTextEdit{AssignTo: &amp;outTE, ReadOnly: true},\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\tPushButton{\r\n\t\t\t\tText: \"\u53d1\u9001\",\r\n\t\t\t\tOnClicked: func() {\r\n\t\t\t\t\toutTE.SetText(strings.ToUpper(inTE.Text()))\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t},\r\n\t}.Run()\r\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u521b\u5efa\u4e00\u4e2aManifest\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n&lt;assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\r\n    &lt;assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"SomeFunkyNameHere\" type=\"win32\"\/>\r\n    &lt;dependency>\r\n        &lt;dependentAssembly>\r\n            &lt;assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"\/>\r\n        &lt;\/dependentAssembly>\r\n    &lt;\/dependency>\r\n    &lt;application xmlns=\"urn:schemas-microsoft-com:asm.v3\">\r\n        &lt;windowsSettings>\r\n            &lt;dpiAwareness xmlns=\"http:\/\/schemas.microsoft.com\/SMI\/2016\/WindowsSettings\">PerMonitorV2, PerMonitor&lt;\/dpiAwareness>\r\n            &lt;dpiAware xmlns=\"http:\/\/schemas.microsoft.com\/SMI\/2005\/WindowsSettings\">True&lt;\/dpiAware>\r\n        &lt;\/windowsSettings>\r\n    &lt;\/application>\r\n&lt;\/assembly><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4f7f\u7528 Go \u8bed\u8a00\u7684 walk \u5e93\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u4f7f\u7528\u5230 Manifest \u6587\u4ef6\u3002Manifest \u6587\u4ef6\u662f\u4e00\u79cd XML \u683c\u5f0f\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5b83\u53ef\u4ee5\u544a\u8bc9\u64cd\u4f5c\u7cfb\u7edf\u5982\u4f55\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u7a0b\u5e8f\u542f\u52a8\u65f6\u5411\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e00\u4e9b\u5143\u6570\u636e\u4fe1\u606f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5177\u4f53\u6765\u8bf4\uff0c\u5728\u4f7f\u7528 walk \u5e93\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u5728\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a &#8220;manifest.xml&#8221; \u7684 Manifest \u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4e0e\u5e94\u7528\u7a0b\u5e8f\u7ed1\u5b9a\u3002\u8fd9\u4e2a Manifest \u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u4e00\u4e9b\u5143\u6570\u636e\u4fe1\u606f\uff0c\u5982\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u3001\u7248\u672c\u53f7\u3001\u56fe\u6807\u7b49\uff0c\u5e76\u6307\u793a\u64cd\u4f5c\u7cfb\u7edf\u5982\u4f55\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u89c1\u7684\u7528\u9014\u662f\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u7ba1\u7406\u5458\u6743\u9650\u3002\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u8bbf\u95ee\u654f\u611f\u8d44\u6e90\u6216\u6267\u884c\u4e00\u4e9b\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u7684\u64cd\u4f5c\uff0c\u90a3\u4e48\u9700\u8981\u5728 Manifest \u6587\u4ef6\u4e2d\u6307\u5b9a\u8be5\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u8fd0\u884c\u5728\u7ba1\u7406\u5458\u6a21\u5f0f\u4e0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u5916\uff0c\u5728 Windows Vista \u548c\u66f4\u9ad8\u7248\u672c\u4e2d\uff0cManifest \u6587\u4ef6\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684 DPI \u611f\u77e5\u5ea6\uff0c\u5e76\u544a\u8bc9\u64cd\u4f5c\u7cfb\u7edf\u5982\u4f55\u5904\u7406\u4e0d\u540c\u5206\u8fa8\u7387\u7684\u663e\u793a\u5668\u3002\u8fd9\u53ef\u4ee5\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u5728\u4e0d\u540c\u7684\u663e\u793a\u5668\u4e0a\u90fd\u6709\u76f8\u540c\u7684\u663e\u793a\u6548\u679c\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\uff0cManifest \u6587\u4ef6\u662f\u4f7f\u7528 walk \u5e93\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u65f6\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\u3002\u901a\u8fc7\u5728 Manifest \u6587\u4ef6\u4e2d\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u5143\u6570\u636e\u4fe1\u606f\u548c\u8981\u6c42\uff0c\u53ef\u4ee5\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5f97\u5230\u6b63\u786e\u7684\u8fd0\u884c\u548c\u5904\u7406\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u4e0b\u8f7d rsrc \u5de5\u5177\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">github\u5730\u5740\u5982\u4e0b\uff1ahttps:\/\/github.com\/akavel\/rsrc<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u548c\u7f16\u8bd1manifest\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go install github.com\/akavel\/rsrc@latest    #\u6267\u884c\u540e\u5728GOPATH\/bin\/\u4e0b\u53ef\u770b\u5230rsrc.exe\nrsrc -manifest test.manifest -o rsrc.syso   #\u751f\u6210rsrc.syso\u6587\u4ef6<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"300\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/10-5.png\" alt=\"\" class=\"wp-image-13258\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/10-5.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/10-5-300x127.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/10-5-600x254.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u6700\u540e\u901a\u8fc7\u8fd0\u884c\u547d\u4ee4\u6784\u5efa\u6210exe\u6587\u4ef6\uff0c\u7136\u540e\u8fd0\u884c\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go build -ldflags=\"-H windowsgui\"  -o new-windows.exe   #-o\u6307\u5b9a\u540d\u5b57\uff0c\u53ef\u4ee5\u4e0d\u52a0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884cnew-windows.exe\uff0c\u5c06\u6253\u5f00\u4e00\u4e2a\u684c\u9762\u7a0b\u5e8f\u7a97\u53e3\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"479\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/2-6.png\" alt=\"\" class=\"wp-image-13266\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/2-6.png 706w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/2-6-300x204.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/04\/2-6-600x407.png 600w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Go \u8bed\u8a00\u7684 walk \u5e93\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa Windows GUI \u5e94\u7528\u7a0b\u5e8f\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7ec4\u7b80\u5355\u800c\u5f3a\u5927\u7684 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":13248,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111,23],"tags":[],"class_list":["post-13246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go","category-rong"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=13246"}],"version-history":[{"count":16,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13246\/revisions"}],"predecessor-version":[{"id":13267,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13246\/revisions\/13267"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/13248"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=13246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=13246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=13246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}