{"id":498,"date":"2009-06-28T19:03:00","date_gmt":"2009-06-28T11:03:00","guid":{"rendered":""},"modified":"2013-11-17T17:24:24","modified_gmt":"2013-11-17T09:24:24","slug":"%e7%a8%8b%e5%ba%8f%e7%aa%97%e4%bd%93%e5%8f%8a%e6%8e%a7%e4%bb%b6%e8%87%aa%e9%80%82%e5%ba%94%e5%88%86%e8%be%a8%e7%8e%87","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/498.html","title":{"rendered":"\u7a0b\u5e8f\u7a97\u4f53\u53ca\u63a7\u4ef6\u81ea\u9002\u5e94\u5206\u8fa8\u7387"},"content":{"rendered":"<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nunit untFixForm;\r\n\r\ninterface\r\n\r\nuses\r\nClasses, SysUtils, Controls, Forms;\r\n\r\ntype\r\nTFontedControl = class(TControl)\r\npublic\r\n    property Font;\r\nend;\r\n\r\nTFontMapping = record\r\n    SWidth : Integer;\r\n    SHeight: Integer;\r\n    FName: string;\r\n    FSize: Integer;\r\nend;\r\n\r\nprocedure FixForm(AForm: TForm);\r\nprocedure SetFontMapping;\r\n\r\nvar\r\nFontMapping : array of TFontMapping;\r\n\r\nimplementation\r\n\r\nprocedure SetFontMapping;\r\nbegin\r\nSetLength(FontMapping, 3);\r\n\r\n\/\/ 800 x 600\r\nFontMapping&#x5B;0].SWidth := 800;\r\nFontMapping&#x5B;0].SHeight := 600;\r\nFontMapping&#x5B;0].FName := '\u5b8b\u4f53';\r\nFontMapping&#x5B;0].FSize := 7;\r\n\r\n\/\/ 1024 x 768\r\nFontMapping&#x5B;1].SWidth := 1024;\r\nFontMapping&#x5B;1].SHeight := 768;\r\nFontMapping&#x5B;1].FName := '\u5b8b\u4f53';\r\nFontMapping&#x5B;1].FSize := 9;\r\n\r\n\/\/ 1280 x 1024\r\nFontMapping&#x5B;2].SWidth := 1280;\r\nFontMapping&#x5B;2].SHeight := 1024;\r\nFontMapping&#x5B;2].FName := '\u5b8b\u4f53';\r\nFontMapping&#x5B;2].FSize := 11;\r\n\r\nend;\r\n\r\nprocedure FixForm(AForm: TForm);\r\nvar\r\ni, j                 : integer;\r\nt                 : TControl;\r\nbegin\r\nwith AForm do\r\nbegin\r\n    for i := 0 to ComponentCount - 1 do\r\n    begin\r\n      try\r\n        t := TControl(Components&#x5B;i]);\r\n        t.left := Trunc(t.left * (Screen.width \/ 1024));\r\n        t.top := Trunc(t.Top * (Screen.Height \/ 768));\r\n        t.Width := Trunc(t.Width * (Screen.Width \/ 1024));\r\n        t.Height := Trunc(t.Height * (Screen.Height \/ 768));\r\n      except\r\n      end; { try }\r\n    end; { for i }\r\n\r\n    for i:= 0 to Length(FontMapping) - 1 do\r\n    begin\r\n      if (Screen.Width = FontMapping&#x5B;i].SWidth) and (Screen.Height = FontMapping&#x5B;i].SHeight) then\r\n      begin\r\n        for j := 0 to ComponentCount - 1 do\r\n        begin\r\n          try\r\n            TFontedControl(Components&#x5B;j]).Font.Name := FontMapping&#x5B;i].FName;\r\n            TFontedControl(Components&#x5B;j]).FONT.Size := FontMapping&#x5B;i].FSize;\r\n          except\r\n          end; { try }\r\n        end; { for j }\r\n      end; { if }\r\n    end; { for i }\r\nend; { with }\r\nend;\r\n\r\ninitialization\r\nSetFontMapping;\r\n\r\nend.\r\n<\/pre>\n<p>SetFontMapping \u65b9\u6cd5\u53ef\u4ee5\u81ea\u884c\u4fee\u6539\uff0c\u4ee5\u9002\u5e94\u66f4\u591a\u7684\u5206\u8fa8\u7387\u3002<\/p>\n<p>\u8c03\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nprocedure TForm1.FormShow(Sender: TObject);\r\nbegin\r\nif MessageBox(Handle,'\u8981\u4f7f\u7528\u5c4f\u5e55\u81ea\u9002\u5e94\u5417\uff1f','\u63d0\u793a',MB_YESNO or MB_ICONINFORMATION) = idno then Exit;\r\nuntFixForm.FixForm(Self);\r\nend;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>unit untFixForm; interface uses Classes, SysUtils, Cont [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-498","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=498"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/498\/revisions"}],"predecessor-version":[{"id":4740,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/498\/revisions\/4740"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}