ContForm.pas
资源名称:delphi.rar [点击查看]
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit ContForm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, OleCtnrs;
- type
- TForm1 = class(TForm)
- OleContainer1: TOleContainer;
- Panel1: TPanel;
- Button1: TButton;
- Button3: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- Document: Variant;
- begin
- // activates if not running
- if not (OleContainer1.State = osRunning) then
- OleContainer1.Run;
- // get the document
- Document := OleContainer1.OleObject;
- // first paragraph to bold
- Document.Paragraphs.Item(1).Range.Bold := 1;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- Document, Paragraph: Variant;
- begin
- // activates if not running
- if not (OleContainer1.State = osRunning) then
- OleContainer1.Run;
- // get the document
- Document := OleContainer1.OleObject;
- // add paragraphs, getting the last one
- Document.Paragraphs.Add;
- Paragraph := Document.Paragraphs.Add;
- // add text to the paragraph, using random font size
- Paragraph.Range.Font.Size := 10 + Random (20);
- Paragraph.Range.Text := 'New text (' +
- IntToStr (Paragraph.Range.Font.Size) + ')'#13;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Randomize;
- end;
- end.