一直没有把样式表系统一下, 春节假期有空, 不能再等了.
为了方便学习, 先写了一个样式表测试工具: CssTest(点击下载)
工具非常简单, 写了 10 行左右的代码; 运行效果图:
![o_091281.gif](https://i-blog.csdnimg.cn/blog_migrate/80d5b56c6fde1f7a4020c4127b6d9f78.gif)
代码文件:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, OleCtrls, SHDocVw; type TForm1 = class(TForm) Memo1: TMemo; Splitter1: TSplitter; Panel1: TPanel; WebBrowser1: TWebBrowser; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Memo1Change(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var path: string; begin Text := 'CssTest'; WebBrowser1.Navigate('about:blank'); Memo1.ScrollBars := ssBoth; with Memo1.Font do begin Name := 'Verdana'; Size := 10; Color := $000080; end; path := ChangeFileExt(ParamStr(0),'.dat'); if FileExists(path) then ReadComponentResFile(path, Memo1); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin WriteComponentResFile(ChangeFileExt(ParamStr(0),'.dat'), Memo1); end; procedure TForm1.Memo1Change(Sender: TObject); begin WebBrowser1.Navigate('about:' + Memo1.Text); end; end.
窗体文件:
object Form1: TForm1 Left = 0 Top = 0 ActiveControl = Memo1 Caption = 'Form1' ClientHeight = 231 ClientWidth = 439 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnClose = FormClose OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Splitter1: TSplitter Left = 241 Top = 0 Height = 231 MinSize = 1 ExplicitLeft = 219 ExplicitHeight = 196 end object Memo1: TMemo Left = 0 Top = 0 Width = 241 Height = 231 Align = alLeft Lines.Strings = ( 'Memo1') TabOrder = 0 OnChange = Memo1Change end object Panel1: TPanel Left = 244 Top = 0 Width = 195 Height = 231 Align = alClient BevelOuter = bvNone Caption = 'Panel1' TabOrder = 1 object WebBrowser1: TWebBrowser Left = 0 Top = 0 Width = 195 Height = 231 Align = alClient TabOrder = 0 ExplicitLeft = 88 ExplicitTop = 88 ExplicitWidth = 300 ExplicitHeight = 150 ControlData = { 4C00000027140000E01700000000000000000000000000000000000000000000 000000004C000000000000000000000001000000E0D057007335CF11AE690800 2B2E126208000000000000004C0000000114020000000000C000000000000046 8000000000000000000000000000000000000000000000000000000000000000 00000000000000000100000000000000000000000000000000000000} end end end