{"id":119,"date":"2007-05-12T14:33:50","date_gmt":"2007-05-12T12:33:50","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/small-fonts-large-fonts-2-formscaler\/"},"modified":"2007-05-12T14:33:52","modified_gmt":"2007-05-12T12:33:52","slug":"small-fonts-large-fonts-2-formscaler","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/small-fonts-large-fonts-2-formscaler\/","title":{"rendered":"Small Fonts \/ Large Fonts (2) &#8211; FormScaler"},"content":{"rendered":"<p><em>In article <3aaefd89_2@dnews>, William Meyer wrote:<\/p>\n<p>> Small fonts\/large fonts is a problem without a clean solution. The<br \/>\n> suggestion will be to develop at large fonts, and the result will work ok on<br \/>\n> small fonts, but it looks funny to me. I&#8217;ve toyed with actually designing<br \/>\n> two sets of forms, and loading them based on the font set in use at runtime.<br \/>\n<\/em><br \/>\nI develop with small fonts and &#8216;Scaled&#8217; set to false.  When I&#8217;m doing<br \/>\ndialog-box style forms I drop a TFormScaler component on the form.  It seems<br \/>\nto work&#8230;<\/p>\n<p>Here&#8217;s TFormScaler &#8211; it&#8217;s quite simple!<br \/>\n<!--more--><br \/>\nfile:\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n[code lang=&#8221;delphi&#8221;]unit cmpFormScaler;<\/p>\n<p>interface<\/p>\n<p>uses<br \/>\n  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<\/p>\n<p>type<br \/>\n  TFormScaler = class(TComponent)<br \/>\n  private<br \/>\n    fScaled : Boolean;<br \/>\n    fDivisor : Integer;<br \/>\n    fMultiplier : Integer;<br \/>\n  protected<br \/>\n    procedure Loaded; override;<br \/>\n  public<br \/>\n    property M : Integer read fMultiplier;<br \/>\n    property D : Integer read fDivisor;<br \/>\n    { Public declarations }<br \/>\n  published<br \/>\n    { Published declarations }<br \/>\n  end;<\/p>\n<p>implementation<\/p>\n<p>const<br \/>\n  SmallFontsI = 454;<\/p>\n<p>{ TFormScaler }<\/p>\n<p>procedure TFormScaler.Loaded;<br \/>\nvar<br \/>\n  frm : TForm;<br \/>\n  s : string;<br \/>\n  c : TCanvas;<br \/>\nbegin<br \/>\n  inherited;<br \/>\n  if not (csDesigning in ComponentState) and not fScaled then<br \/>\n  begin<br \/>\n    fScaled := True;<br \/>\n    if Owner is TForm then<br \/>\n    begin<br \/>\n      frm := TForm (Owner);<br \/>\n      frm.Scaled := False;<\/p>\n<p>      c := TCanvas.Create;<br \/>\n      c.Handle := GetDC (HWND_DESKTOP);<\/p>\n<p>      try<br \/>\n        s :=<br \/>\n&#8216;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=+_)(*&#038;^%$\u00a3&#8221;!&#8217;<br \/>\n;<br \/>\n        fMultiplier := c.TextWidth (s);<\/p>\n<p>        fDivisor := SmallFontsI;<br \/>\n        frm.ScaleBy (fMultiplier, fDivisor);<br \/>\n      finally<br \/>\n        ReleaseDC (HWND_DESKTOP, c.Handle);<br \/>\n   c.Free<br \/>\n      end<br \/>\n    end<br \/>\n  end<br \/>\nend;<\/p>\n<p>end.<br \/>\n[\/code]<\/p>\n<p>[tags]Delphi, Forms[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In article &lt;3aaefd89_2@dnews>, William Meyer wrote: > Small fonts\/large fonts is a problem without a clean solution. The > suggestion will be to&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,100],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-1V","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/119"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}