1、32位深度历险中有字体编程的源码<br>Delphi园地<br>http://mydelphi.8u8.com附书源码单元<br>2、<br>procedure SetResolution(ResX, ResY: DWord);<br>var<br>lDeviceMode : TDeviceMode;<br>begin<br>EnumDisplaySettings(nil, 0, lDeviceMode);<br>lDeviceMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT;<br>lDeviceMode.dmPelsWidth :=ResX;<br>lDeviceMode.dmPelsHeight:=ResY;<br>ChangeDisplaySettings(lDeviceMode, 0);<br>end;<br>****************<br>implementation<br>const<br> ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}<br> ScreenHeight: LongInt = 600;<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br> i, OldFormWidth: integer;<br>begin<br> scaled := true;<br> if (screen.width <> ScreenWidth) then begin<br> OldFormWidth := width;<br> height := longint(height) * longint(screen.height) DIV ScreenHeight;<br> width := longint(width) * longint(screen.width) DIV ScreenWidth;<br><br> scaleBy(screen.width, ScreenWidth);<br> font.size := (Width DIV OldFormWidth) * font.size;<br> end;<br>end;<br><br><br>Then, you will want to have something that checks to see that the font<br>sizes are OK. Before you change the font's size, you would need to ensure<br>the object actually has a font property by checking the RTTI. This can be<br>done as follows:<br><br>USES TypInfo; {Add this to your USES statement.}<br><br>var<br> i: integer;<br>begin<br> for i := componentCount - 1 downto 0 do<br> with components do<br> begin<br> if GetPropInfo(ClassInfo, 'font') <> nil then<br> font.size := (NewFormWidth DIV OldFormWidth) * font.size;<br><br> end;<br>end;<br>