AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Tabs im RichEdit

Ein Thema von Bent1995 · begonnen am 11. Nov 2009 · letzter Beitrag vom 20. Nov 2009
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#11

Re: Tabs im RichEdit

  Alt 13. Nov 2009, 15:57
Ja genau das,
Denn wenn wir nicht wissen was Du machst, dann können wir Dir schlecht sagen wo der Fehler steckt.

Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat
Bent1995

Registriert seit: 16. Okt 2009
50 Beiträge
 
#12

Re: Tabs im RichEdit

  Alt 13. Nov 2009, 16:51
Joa hier ist der Source code:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, ComCtrls, ToolWin, XPMan, ImgList, ExtCtrls, Registry,
  IdBaseComponent, IdComponent, IdIPWatch, ScktComp;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Home1: TMenuItem;
    Datei1: TMenuItem;
    Ansicht1: TMenuItem;
    Extras1: TMenuItem;
    Einstellungen1: TMenuItem;
    Info1: TMenuItem;
    N1: TMenuItem;
    ProgrammBeenden1: TMenuItem;
    extdokumentffnen1: TMenuItem;
    extdokumentabspeichern1: TMenuItem;
    N2: TMenuItem;
    extdokumentspeichernunter1: TMenuItem;
    extdokumentalsWebsitespeichern1: TMenuItem;
    Bearbeiten1: TMenuItem;
    Kopieren1: TMenuItem;
    Ausschneiden1: TMenuItem;
    Einfgen1: TMenuItem;
    Allesmarkieren1: TMenuItem;
    N3: TMenuItem;
    Rckgngig1: TMenuItem;
    N4: TMenuItem;
    extsuchen1: TMenuItem;
    extersetzen1: TMenuItem;
    Hintergrundfarbeauswhlen1: TMenuItem;
    N5: TMenuItem;
    Lesemodus1: TMenuItem;
    Lesemodusdeaktievieren1: TMenuItem;
    aschenrechner1: TMenuItem;
    ToolBar1: TToolBar;
    StatusBar1: TStatusBar;
    ImageList1: TImageList;
    XPManifest1: TXPManifest;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    ColorDialog1: TColorDialog;
    PrintDialog1: TPrintDialog;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    ToolButton12: TToolButton;
    ToolButton13: TToolButton;
    ToolButton14: TToolButton;
    ToolButton15: TToolButton;
    ToolButton16: TToolButton;
    ToolButton17: TToolButton;
    ToolButton18: TToolButton;
    ToolButton19: TToolButton;
    ToolButton20: TToolButton;
    ComboBoxEx2: TComboBoxEx;
    ToolButton21: TToolButton;
    ComboBoxEx1: TComboBoxEx;
    ColorDialog2: TColorDialog;
    N6: TMenuItem;
    extdokumentausdrucken1: TMenuItem;
    FindDialog1: TFindDialog;
    ReplaceDialog1: TReplaceDialog;
    N7: TMenuItem;
    NeuesDokument1: TMenuItem;
    Internetbrowser1: TMenuItem;
    Timer1: TTimer;
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Button1: TButton;
    extberLanSenden1: TMenuItem;
    ServerSocket1: TServerSocket;
    ClientSocket1: TClientSocket;
    IdIPWatch1: TIdIPWatch;
    N8: TMenuItem;
    Button2: TButton;
    Timer2: TTimer;
    CheckBox1: TCheckBox;
    Button3: TButton;
    Label3: TLabel;
    Edit2: TEdit;
    Panel2: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    RichEdit1: TRichEdit;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    RichEdit2: TRichEdit;
    RichEdit3: TRichEdit;
    HeaderControl1: THeaderControl;
    procedure ProgrammBeenden1Click(Sender: TObject);
    procedure Info1Click(Sender: TObject);
    procedure extdokumentffnen1Click(Sender: TObject);
    procedure extdokumentabspeichern1Click(Sender: TObject);
    procedure Hintergrundfarbeauswhlen1Click(Sender: TObject);
    procedure aschenrechner1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure RichEdit1Change(Sender: TObject);
    procedure ComboBoxEx1Change(Sender: TObject);
    procedure ComboBoxEx2Change(Sender: TObject);
    procedure ToolButton15Click(Sender: TObject);
    procedure ToolButton14Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure extdokumentausdrucken1Click(Sender: TObject);
    procedure Lesemodus1Click(Sender: TObject);
    procedure Lesemodusdeaktievieren1Click(Sender: TObject);
    procedure RichEdit1KeyPress(Sender: TObject; var Key: Char);
    procedure Kopieren1Click(Sender: TObject);
    procedure Ausschneiden1Click(Sender: TObject);
    procedure Einfgen1Click(Sender: TObject);
    procedure Allesmarkieren1Click(Sender: TObject);
    procedure Rckgngig1Click(Sender: TObject);
    procedure ReplaceDialog1Replace(Sender: TObject);
    procedure FindDialog1Find(Sender: TObject);
    procedure ToolButton18Click(Sender: TObject);
    procedure extersetzen1Click(Sender: TObject);
    procedure extsuchen1Click(Sender: TObject);
    procedure ToolButton19Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure ToolButton12Click(Sender: TObject);
    procedure NeuesDokument1Click(Sender: TObject);
    procedure extdokumentspeichernunter1Click(Sender: TObject);
    procedure Internetbrowser1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Einstellungen1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure extberLanSenden1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure ServerSocket1ClientRead(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ServerSocket1ClientConnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ServerSocket1ClientDisconnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Timer2Timer(Sender: TObject);
    procedure ServerSocket2ClientRead(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure CheckBox1Click(Sender: TObject);
    procedure RichEdit2Change(Sender: TObject);
    procedure RichEdit3Change(Sender: TObject);
    procedure RichEdit2KeyPress(Sender: TObject; var Key: Char);
    procedure RichEdit3KeyPress(Sender: TObject; var Key: Char);
    procedure RichEdit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RichEdit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RichEdit1SelectionChange(Sender: TObject);
    procedure PageControl1Changing(Sender: TObject;
      var AllowChange: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  PreviousFoundPos: integer;
  Change: Integer;
  Full: String;
  Speed: Integer;

implementation

uses Unit2, Unit3, Unit4, Unit5, Unit7;

{$R *.dfm}

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

procedure TForm1.Info1Click(Sender: TObject);
begin
Form7.Visible:= True;
end;

procedure TForm1.extdokumentffnen1Click(Sender: TObject);
begin
If OpenDialog1.Execute then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Lines.LoadFromFile(OpenDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Lines.LoadFromFile(OpenDialog1.FileName);
end;
end;

procedure TForm1.extdokumentabspeichern1Click(Sender: TObject);
begin
if Fileexists (Savedialog1.FileName) = true then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Lines.SaveToFile(SaveDialog1.FileName);
  change:= 0;
end
  else
begin
  extdokumentspeichernunter1.Click;
  end;
end;

procedure TForm1.Hintergrundfarbeauswhlen1Click(Sender: TObject);
begin
If ColorDialog1.Execute then
begin
RichEdit1.Color:= ColorDialog1.Color;
end;
end;

procedure TForm1.aschenrechner1Click(Sender: TObject);
begin
Form2.Visible:= True;
end;

procedure TForm1.FormCreate(Sender: TObject);
var regist: TRegistry;
begin
StatusBar1.Panels[0].Text:= 'Es ist jetzt: ' + TimeToStr(Now) + ' und wir haben heute den: ' + DateToStr(Now);
Label2.Caption:= 'Ihre aktuelle IP: ' + IdIPWatch1.LocalIP;
ComboBoxEx2.Items := Screen.Fonts;
RichEdit1.SelAttributes.Name:=ComboboxEx2.Text;
Richedit1.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
Speed:= 10;
  regist := TRegistry.Create;
  try
    regist.RootKey := HKEY_CURRENT_USER;
    try
      regist.OpenKey('Software\Texteditor\Texteditor2010\0.1', true);
      ComboBoxEx2.Text:= regist.ReadString('Schriftart');
      ComboBoxEx1.Text:= regist.ReadString('Schriftgröße');
    except
      Form1.Left := 0;
      Form1.Top := 0;
    end;
  finally
    regist.free;
  end;
end;

procedure TForm1.RichEdit1Change(Sender: TObject);
begin
RichEdit1.SelAttributes.Name:=ComboboxEx2.Text;
Richedit1.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
Rckgngig1.Enabled:= True;
If CheckBox1.Checked = True then
begin
  ClientSocket1.Port := 23;
  ClientSocket1.Host := Edit1.Text;
  ClientSocket1.Socket.SendText(RichEdit1.Text);
  sleep(Speed);
end;
end;

procedure TForm1.ComboBoxEx1Change(Sender: TObject);
begin
Richedit1.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
end;

procedure TForm1.ComboBoxEx2Change(Sender: TObject);
begin
RichEdit1.SelAttributes.Name:=ComboboxEx2.Text;
ComboBoxEx2.Font.Name:= ComboBoxEx2.Text;
RichEdit2.SelAttributes.Name:=ComboboxEx2.Text;
RichEdit3.SelAttributes.Name:=ComboboxEx2.Text;
end;

procedure TForm1.ToolButton15Click(Sender: TObject);
begin
If ColorDialog2.Execute then
begin
Richedit1.SelAttributes.Color:= ColorDialog2.Color;
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.SelAttributes.Color:= ColorDialog2.Color;
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.SelAttributes.Color:= ColorDialog2.Color;
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.SelAttributes.Color:= ColorDialog2.Color;
end;
end;

procedure TForm1.ToolButton14Click(Sender: TObject);
begin
if ToolButton14.Down then
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style + [fsStrikeOut];
end
else
begin
Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style - [fsStrikeOut]
end;
begin
if ToolButton14.Down then
begin
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style + [fsStrikeOut]
end
else
begin
Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style - [fsStrikeOut]
end;
begin
if ToolButton14.Down then
begin
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style + [fsStrikeOut]
end
else
begin
Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style - [fsStrikeOut];
end;
end;
end;
end;

procedure TForm1.ToolButton6Click(Sender: TObject);
begin
if ToolButton6.Down then
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style + [fsBold];
end
else
begin
Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style - [fsBold];
end;
begin
if ToolButton6.Down then
begin
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style + [fsBold]
end
else
begin
Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style - [fsBold];
end;
begin
if ToolButton6.Down then
begin
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style + [fsBold]
end
else
begin
Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style - [fsBold];
end;
end;
end;
end;

procedure TForm1.ToolButton7Click(Sender: TObject);
begin
if ToolButton7.Down then
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style + [fsItalic];
end
else
begin
Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style - [fsItalic]
end;
begin
if ToolButton7.Down then
begin
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style + [fsItalic]
end
else
begin
Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style - [fsItalic]
end;
begin
if ToolButton7.Down then
begin
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style + [fsItalic]
end
else
begin
Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style - [fsItalic];
end;
end;
end;
end;

procedure TForm1.ToolButton8Click(Sender: TObject);
begin
if ToolButton8.Down then
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style + [fsUnderline];
end
else
begin
Richedit1.SelAttributes.Style:=Richedit1.SelAttributes.Style - [fsUnderline]
end;
begin
if ToolButton8.Down then
begin
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style + [fsUnderline]
end
else
begin
Richedit2.SelAttributes.Style:=Richedit2.SelAttributes.Style - [fsUnderline]
end;
begin
if ToolButton8.Down then
begin
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style + [fsUnderline]
end
else
begin
Richedit3.SelAttributes.Style:=Richedit3.SelAttributes.Style - [fsUnderline];
end;
end;
end;
end;

procedure TForm1.ToolButton4Click(Sender: TObject);
begin
If PrintDialog1.Execute then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Print('');
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Print('');
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Print('');
end;
end;

procedure TForm1.ToolButton1Click(Sender: TObject);
begin
If OpenDialog1.Execute then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Lines.LoadFromFile(OpenDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Lines.LoadFromFile(OpenDialog1.FileName);
end;
end;

procedure TForm1.ToolButton2Click(Sender: TObject);
begin
if Fileexists (Savedialog1.FileName) = true then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Lines.SaveToFile(SaveDialog1.FileName);
end
  else
begin
  extdokumentspeichernunter1.Click;
  end;
end;

procedure TForm1.ToolButton3Click(Sender: TObject);
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Clear;
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Clear;
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Clear;
Rckgngig1.Enabled:= False;
Change:= 0;
end;

procedure TForm1.extdokumentausdrucken1Click(Sender: TObject);
begin
If PrintDialog1.Execute then
begin
RichEdit1.Print('');
end;
end;

procedure TForm1.Lesemodus1Click(Sender: TObject);
begin
RichEdit1.ReadOnly:= True;
Lesemodus1.Visible:= False;
Lesemodusdeaktievieren1.Visible:= True;
end;

procedure TForm1.Lesemodusdeaktievieren1Click(Sender: TObject);
begin
RichEdit1.ReadOnly:= False;
Lesemodus1.Visible:= True;
Lesemodusdeaktievieren1.Visible:= False;
end;

procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
RichEdit1.SelAttributes.Name:=ComboboxEx2.Text;
Change:= 1;
end;

procedure TForm1.Kopieren1Click(Sender: TObject);
begin
Richedit1.CopytoClipboard;
end;

procedure TForm1.Ausschneiden1Click(Sender: TObject);
begin
Richedit1.Cuttoclipboard;
end;

procedure TForm1.Einfgen1Click(Sender: TObject);
begin
Richedit1.PasteFromClipboard;
end;

procedure TForm1.Allesmarkieren1Click(Sender: TObject);
begin
RichEdit1.SelectAll;
end;

procedure TForm1.Rckgngig1Click(Sender: TObject);
begin
RichEdit1.Undo;
end;

procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
var
 SelPos, SPos, SLen, TextLength: Integer;
 SearchString : string;
begin
 with TReplaceDialog(Sender) do begin
  TextLength:=Length(RichEdit1.Lines.Text);

  SPos:=RichEdit1.SelStart;
  SLen:=RichEdit1.SelLength;

  SearchString := Copy(RichEdit1.Lines.Text,
                       SPos + SLen + 1,
                       TextLength - SLen + 1);
  SelPos := Pos(FindText, SearchString);
  if SelPos > 0 then begin
    RichEdit1.SelStart := (SelPos - 1) + (SPos + SLen);
    RichEdit1.SelLength := Length(FindText);
    RichEdit1.SelText := ReplaceText;
  end
  else MessageDlg('Konnte Elemnt nicht finden "' + FindText +
      '"', mtError, [mbOk], 0);
  end;

end;

procedure TForm1.FindDialog1Find(Sender: TObject);
var
  sText: string;
  StartFrom, FoundPos: integer;
begin
  if PreviousFoundPos = 0 then
    FindDialog1.Options := FindDialog1.Options - [frFindNext];
  if not (frFindNext in FindDialog1.Options) then begin
    sText := RichEdit1.Text;
    StartFrom := 1;
  end
  else begin
    StartFrom := PreviousFoundPos + Length(FindDialog1.Findtext);
    sText := Copy(RichEdit1.Text, StartFrom, Length(RichEdit1.Text) - StartFrom + 1);
  end;
  if frMatchCase in FindDialog1.Options then
    FoundPos := Pos(FindDialog1.FindText, sText)
  else
    FoundPos := Pos(UpperCase(FindDialog1.FindText), UpperCase(sText));
  if FoundPos > 0 then begin
    PreviousFoundPos := FoundPos + StartFrom - 1;
    RichEdit1.SelStart := PreviousFoundPos - 1;
    RichEdit1.SelLength := Length(FindDialog1.FindText);
    RichEdit1.SetFocus;
  end
  else
    ShowMessage('Konnte gesuchtes Element nicht finden! "' + FindDialog1.FindText + '"');
end;

procedure TForm1.ToolButton18Click(Sender: TObject);
begin
  PreviousFoundPos := 0;
  FindDialog1.Execute;
end;

procedure TForm1.extersetzen1Click(Sender: TObject);
begin
ReplaceDialog1.Execute;
end;

procedure TForm1.extsuchen1Click(Sender: TObject);
begin
  PreviousFoundPos := 0;
  FindDialog1.Execute;
end;

procedure TForm1.ToolButton19Click(Sender: TObject);
begin
ReplaceDialog1.Execute;
end;

procedure TForm1.ToolButton10Click(Sender: TObject);
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.Paragraph.Alignment:=taLeftJustify;
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.Paragraph.Alignment:=taLeftJustify;
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.Paragraph.Alignment:=taLeftJustify;
ToolButton10.Down:= True;
ToolButton11.Down:=False;
ToolButton12.Down:=False;
end;

procedure TForm1.ToolButton11Click(Sender: TObject);
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.Paragraph.Alignment:=taCenter;
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.Paragraph.Alignment:=taCenter;
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.Paragraph.Alignment:=taCenter;
ToolButton11.Down:= True;
ToolButton10.Down:=False;
ToolButton12.Down:=False;
end;

procedure TForm1.ToolButton12Click(Sender: TObject);
begin
If Pagecontrol1.ActivePageIndex = 0 then Richedit1.Paragraph.Alignment:=taRightJustify;
If Pagecontrol1.ActivePageIndex = 1 then Richedit2.Paragraph.Alignment:=taRightJustify;
If Pagecontrol1.ActivePageIndex = 2 then Richedit3.Paragraph.Alignment:=taRightJustify;
ToolButton12.Down:= True;
ToolButton10.Down:=False;
ToolButton11.Down:=False;
end;

procedure TForm1.NeuesDokument1Click(Sender: TObject);
begin
RichEdit1.Clear;
Rckgngig1.Enabled:= False;
Change := 0;
end;

procedure TForm1.extdokumentspeichernunter1Click(Sender: TObject);
begin
If SaveDialog1.Execute then
begin
If Pagecontrol1.ActivePageIndex = 0 then RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 1 then RichEdit2.Lines.SaveToFile(SaveDialog1.FileName);
If Pagecontrol1.ActivePageIndex = 2 then RichEdit3.Lines.SaveToFile(SaveDialog1.FileName);
change:= 0;
end;
end;

procedure TForm1.Internetbrowser1Click(Sender: TObject);
begin
Form3.Visible:= True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
If Fileexists (SaveDialog1.FileName) = true then
begin
RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
end
else RichEdit1.Lines.SaveToFile('Autosave Texteditor 2010' + DateToStr(Now));
end;

procedure TForm1.Einstellungen1Click(Sender: TObject);
begin
Form5.Visible:= True;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
Richedit1.Align:= alClient;
Richedit2.Align:= alClient;
Richedit3.Align:= alClient;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var regist: TRegistry;
begin
If Change > 0 then
begin
if MessageDlg('Wollen Sie vor dem Beenden speichern?', mtConfirmation, [mbYes, mbNo], 0)=mrYes then
ToolButton2.Click;
  regist:=TRegistry.Create;
  try
    regist.RootKey:=HKEY_CURRENT_USER;
    regist.OpenKey('Software\Texteditor\Texteditor2010\0.1', true);
    regist.WriteString('Schriftart', ComboBoxEx2.Text);
    regist.WriteString('Schriftgröße', ComboBoxEx1.Text);
    regist.WriteString('Vollversion', Form1.Caption);
  finally
    regist.free;
  end;
end;
end;

procedure TForm1.extberLanSenden1Click(Sender: TObject);
begin
Panel1.Visible:= True;
ServerSocket1.Active:= True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
If Edit1.Text <> 'then
begin
  ClientSocket1.Port := 23;
  ClientSocket1.Host := Edit1.Text;
  ClientSocket1.Socket.SendText(RichEdit1.Text);
  sleep(500);
end
else ShowMessage('Es wurde kein, oder ein Falscher Empfänger eingegeben!');
end;

procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  i: integer;
  sRec: string;
begin
  for i := 0 to ServerSocket1.Socket.ActiveConnections-1 do
  begin
    with ServerSocket1.Socket.Connections[i] do
    begin
      sRec := ReceiveText;
      sleep (50);
      if sRec <> 'then
      begin
        RichEdit1.Text:=(sRec);
      end;
    end;
  end;
end;

procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
Edit2.Text:= 'Ein Client ist verbunden!';
Label3.Enabled:= True;
end;

procedure TForm1.ServerSocket1ClientDisconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
Edit2.Text:= 'Ein Client ist gegangen!';
Label3.Enabled:= False;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ClientSocket1.Port := 23;
  ClientSocket1.Host := Edit1.Text;
  ClientSocket1.Active := True;
  ServerSocket1.Active:= True;
  Button1.Enabled:= True;
  CheckBox1.Enabled := True;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Panel1.Visible:= False;
end;

procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
Richedit1.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
RichEdit1.SelStart := Length(RichEdit1.Lines.Text);
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
StatusBar1.Panels[0].Text:= 'Es ist jetzt: ' + TimeToStr(Now) + ' und wir haben heute den: ' + DateToStr(Now);
end;

procedure TForm1.ServerSocket2ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  i: integer;
  sRec: string;
begin
  for i := 0 to ServerSocket1.Socket.ActiveConnections-1 do
  begin
    with ServerSocket1.Socket.Connections[i] do
    begin
      sRec := ReceiveText;
      if sRec <> 'then
      begin
        RichEdit1.Text:=(sRec);
        Form1.Show;
      end;
    end;
  end;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
If CheckBox1.Checked = True then
begin
if MessageDlg('Haben Sie eine schnelle Internetverbindung? (mind. über 10000 kbits pro Sekunde) Da sonst die Sendeeinstellungen automatisch angepasst werden. Klicken Sie bitte nur "Yes" wenn Sie wirklich eine schnelle Internetverbindung habe!', mtConfirmation, [mbYes, mbNo], 0)=mrYes then
begin
speed:= 10;
CheckBox1.Checked:= True;
Button1.Enabled:= False;
end
else
Speed:= 200;
end
else Checkbox1.Checked:= False;
end;

procedure TForm1.RichEdit2Change(Sender: TObject);
begin
RichEdit2.SelAttributes.Name:=ComboboxEx2.Text;
Richedit2.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
Rckgngig1.Enabled:= True;
end;

procedure TForm1.RichEdit3Change(Sender: TObject);
begin
RichEdit3.SelAttributes.Name:=ComboboxEx2.Text;
Richedit3.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
Rckgngig1.Enabled:= True;
end;

procedure TForm1.RichEdit2KeyPress(Sender: TObject; var Key: Char);
begin
RichEdit2.SelAttributes.Name:=ComboboxEx2.Text;
Change:= 1;
end;

procedure TForm1.RichEdit3KeyPress(Sender: TObject; var Key: Char);
begin
RichEdit3.SelAttributes.Name:=ComboboxEx2.Text;
Change:= 1;
end;

procedure TForm1.RichEdit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
Richedit2.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
RichEdit2.SelStart := Length(RichEdit1.Lines.Text);
end;

procedure TForm1.RichEdit3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
Richedit3.SelAttributes.Size:=Strtoint(ComboboxEx1.text);
RichEdit3.SelStart := Length(RichEdit1.Lines.Text);
end;

procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
if fsBold in Richedit1.SelAttributes.Style then
  begin
    ToolButton6.Down:=true;
  end else
   begin
    ToolButton6.Down:=false;

    if fsitalic in Richedit1.SelAttributes.Style then
  begin
    ToolButton7.Down:=true;
  end else
   begin
    ToolButton7.Down:=false;

    if fsunderline in Richedit1.SelAttributes.Style then
  begin
    ToolButton8.Down:=true;
  end else
   begin
  ToolButton8.Down:=false;

case Richedit1.Paragraph.Alignment of
taLeftJustify: begin Toolbutton10.Down:=true; Toolbutton11.Down:=false; Toolbutton12.Down:=false; end;
taCenter: begin Toolbutton11.Down:=true; Toolbutton10.Down:=false; Toolbutton12.Down:=false; end;
taRightJustify: begin Toolbutton12.Down:=true; Toolbutton11.Down:=false; Toolbutton10.Down:=false; end;
end;
end;
end;
end;
end;

procedure TForm1.PageControl1Changing(Sender: TObject;
  var AllowChange: Boolean);
begin
Toolbutton6.Down:= False;
Toolbutton7.Down:= False;
Toolbutton8.Down:= False;
Toolbutton14.Down:= False;
Toolbutton10.Down:= False;
Toolbutton11.Down:= False;
Toolbutton12.Down:= False;
end;

end.
  Mit Zitat antworten Zitat
Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#13

Re: Tabs im RichEdit

  Alt 13. Nov 2009, 17:39
Hallo Bent1995,

ganz so viel hät es ja auch nicht sein müssen.
Ich vermute mal es knackt hier:
Delphi-Quellcode:
procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
var
SelPos, SPos, SLen, TextLength: Integer;
SearchString : string;
begin
with TReplaceDialog(Sender) do begin
  TextLength:=Length(RichEdit1.Lines.Text);

  SPos:=RichEdit1.SelStart;
  SLen:=RichEdit1.SelLength;

  SearchString := Copy(RichEdit1.Lines.Text,
                       SPos + SLen + 1,
                       TextLength - SLen + 1);
  SelPos := Pos(FindText, SearchString);
  if SelPos > 0 then begin
    RichEdit1.SelStart := (SelPos - 1) + (SPos + SLen);
    RichEdit1.SelLength := Length(FindText);
    RichEdit1.SelText := ReplaceText;
  end
  else MessageDlg('Konnte Elemnt nicht finden "' + FindText +
      '"', mtError, [mbOk], 0);
  end;

end;
SelPos gibt die Position innerhalb Textabschnittes (Searchstring)an , der hinter dem selektierten Text liegt.
Was Du aber benötigst ist die Position im vollständigen Text also
SelPos:=Selpos+Spos+Slen; Da Selpos für das erste Zeichen 0 benutzt und Pos die 1 müßtest Du da ggf. noch etwas Feintuning betreiben.

Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat
Bent1995

Registriert seit: 16. Okt 2009
50 Beiträge
 
#14

Re: Tabs im RichEdit

  Alt 20. Nov 2009, 15:34
Danke aber:

Ich meinte etwas anderes. Also wenn ich jetzt einen Text geschrieben habe, und dann versuche aus der Mitte eines Wortes einen Buchstaben zu löschen, dann löscht der immer nur den letzten Buchstaben des Wortes, das ist genauso wenn man das gesamte Wort makiert und dann die lösch Taste drückt, löscht er nur den letzten Buchstaben...

mfg Bent
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz