HOME  FORUM  LINKS

Site Menu

Development

Director

Hosting Support

Quick Links

Delphi Topics

Some Delphi code snippets aimed primarily at the novice Delphi user

TPageControl Example

This is a simple example to demonstrate some of the formatting parameters for the TRichEdit control. Download Project

{-----------------------------------------------------------------------------
 Unit Name: RichUnit1
 Author:    Tony Domigan DOMAJ Pty. Ltd.
 Purpose:  Demonstrate TRichEdit Formattting
 History:
-----------------------------------------------------------------------------}

unit RichUnit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AppEvnts, StdCtrls,ExtCtrls, ComCtrls ;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ApplicationEvents1: TApplicationEvents;
    RichTest: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
    procedure FormDestroy(Sender: TObject);
    procedure RichTestClick(Sender: TObject);
  private
    { Private declarations }
  public
    slErrorLog: TStrings;
    FCre8LogFile: Boolean;
    FAllowResizing: Boolean;
    property Cre8LogFile: Boolean read FCre8LogFile write FCre8LogFile;
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses SPConsts;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Cre8LogFile := True;
end;

procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
  E: Exception);
begin
  if not Cre8LogFile then
    Exit;
  with slErrorLog do begin
    Add(Format('%s: %s',[SDelphiErrorMessage, E.Message]));
    Add(Format('%s: %d %s',[SWindowsErrorCodeAndMessage,
                            GetLastError, SysErrorMessage(GetLastError)]));
    Add(DateTimeToStr(Now));
    Add(TimeToStr(Now));
    Add('');
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  if not Cre8LogFile then
    Exit;
  if Assigned(slErrorLog) then begin
    if slErrorLog.Count>0 then
      slErrorLog.SaveToFile(Format('%s.txt', [SAppErrorLog]));
    slErrorLog.Free;
  end;
end;

procedure TForm1.RichTestClick(Sender: TObject);
const cS: String = '01234 567890 abcde fghijk lmnop qrs tuv wxyz. ';
var iIterate:Integer;
begin
with TRichEdit.Create(Self) do
  begin
    Parent := Self;
    Align := alClient;
    Lines.Clear;
    Lines.Add('Use Bullet Points:');
    // set numbering style
    Paragraph.Numbering := nsBullet;
    for iIterate:=0 to 4 do Lines.Add(cS);
    //disable bullets and set alignment centre.
    Paragraph.Numbering := nsNone;
    Paragraph.Alignment := taCenter;
    Lines.Add('Alignment(Centred):');
    //set alignment left
    Paragraph.Alignment := taLeftJustify;
    Lines.Add('Left Aligned');
    //set alignment right
    Paragraph.Alignment := taRightJustify;
    Lines.Add('Right Aligned');
    //set alignment left
    Paragraph.Alignment := taLeftJustify;
    //set right and left indents to 100
    Paragraph.RightIndent := 100;
    Paragraph.LeftIndent := 100;
    Lines.Add('Para Indent: '+cS+cS+cS+cS+cS);
    //reset left indent to 60
    Paragraph.FirstIndent := 60;
    Lines.Add('Para Indent: '+cS+cS+cS+cS+cS);
    //reset left indent to 0
    Paragraph.LeftIndent := 0;
    Lines.Add('Second Line (indented by 0 but firstIndent still active)');
    //reset firstindent to 0
    Paragraph.FirstIndent := 0;
    Lines.Add('Third Line (indented by 0 but firstIndent is 0)');
  end;

end;

end.

The project code resides in a button on an otherwise empty form.See below for the screen output.

Recent Topics

The latest topics from the forum.

  1. k-director.com: Post Updates
  2. A blog about Adobe Director
  3. Centerstage
  4. Custom Cursor...Why It Does Not Work?
  5. Director Game!
  6. cross platform
  7. database xtra for both mac and windows
  8. from windows to MAC
  9. SLIDER POSITION...
  10. Bullet points in text member
  11. Any VideoOut plugin / xtras for director mx ??
  12. Activex component install
  13. quiz
  14. how to export embedded flash swf?
  15. A BIG PROBLEM...
  16. Spining a model on a touchscreen
  17. 3D Fountain trail to avoid the Cursor
  18. HTTP
  19. SHOCKWAVE VIDEO
  20. Deleting Lines Comparing Time...I Have No Idea...
  21. Property not found error
  22. SHOCKWAVE PROBLEM
  23. PROBLEM SHOCKWAVE
  24. text field focus
  25. ExitLock CloseRequest Quit Close Gadget
  26. convert read only
  27. F10 Key Code Does Not Work
  28. Director Game Development Survey
  29. baPrintFile()
  30. How do check if a printer is printing??

Useful Links

Google Translate
AltaVista Translate
Google Glossary

Google
Web www.domaj.com