PCTurk | Aşk Sevgi Resimleri , Mektupları , silkroad , komik msn avatarlar (Arşiv Ana sayfa) => Delphi

Konu: Wordpad Örneği

Sayfa: [ 1 ]

sWaGg€r 06.07.2008 17:57:55
unit anaform;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, StdActns, ActnList, ImgList, StdCtrls, Menus;

type
  TForm1 = class(TForm)
    OpenDialog: TOpenDialog;
    SaveDialog: TSaveDialog;
    ToolbarImages: TImageList;
    ActionList1: TActionList;
    duzengerial: TEditUndo;
    duzenkes: TEditCut;
    duzenkopyala: TEditCopy;
    duzenyapistir: TEditPaste;
    duzenyazitipi: TAction;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    PrintDialog: TPrintDialog;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    ComboBox1: TComboBox;
    ToolButton11: TToolButton;
    yaziboyutu: TEdit;
    UpDown1: TUpDown;
    ToolButton12: TToolButton;
    kalin: TToolButton;
    MainMenu1: TMainMenu;
    Dosya1: TMenuItem;
    Yeni1: TMenuItem;
    A1: TMenuItem;
    N1: TMenuItem;
    Kaydet1: TMenuItem;
    Farklikaydet1: TMenuItem;
    N2: TMenuItem;
    Yazdr1: TMenuItem;
    N3: TMenuItem;
    k1: TMenuItem;
    Dzen1: TMenuItem;
    Gerial1: TMenuItem;
    N4: TMenuItem;
    Kes1: TMenuItem;
    Kopyala1: TMenuItem;
    Yaptr1: TMenuItem;
    N5: TMenuItem;
    Yazitipise1: TMenuItem;
    sayfa: TRichEdit;
    ActionList2: TActionList;
    dosyayeni: TAction;
    dosyakaydet: TAction;
    dosyayazdir: TFilePrintSetup;
    cikis: TAction;
    FontDialog1: TFontDialog;
    italik: TToolButton;
    alticizgili: TToolButton;
    ToolButton15: TToolButton;
    solayasla: TToolButton;
    ortala: TToolButton;
    sagayasla: TToolButton;
    ToolButton19: TToolButton;
    isaretle: TToolButton;
    PopupMenu1: TPopupMenu;
    Gerial2: TMenuItem;
    N6: TMenuItem;
    Kes2: TMenuItem;
    Kopyala2: TMenuItem;
    Yaptr2: TMenuItem;
    N7: TMenuItem;
    Yazitipi1: TMenuItem;
    Grnm1: TMenuItem;
    Araubuu1: TMenuItem;
    dosyaac: TAction;
    procedure yenibutton(Sender: TObject);
    procedure acbutton(Sender: TObject);
    procedure kaydetbutton(Sender: TObject);
    procedure duzengerialbutton(Sender: TObject);
    procedure duzenkesbutton(Sender: TObject);
    procedure duzenkopyalabutton(Sender: TObject);
    procedure duzenyapistirbutton(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure yaziboyutuChange(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure kalinbutton(Sender: TObject);
    procedure programcikis(Sender: TObject);
    procedure yazitipi(Sender: TObject);
    procedure italikbutton(Sender: TObject);
    procedure alticizgilibutton(Sender: TObject);
    procedure solayaslabutton(Sender: TObject);
    procedure ortalabutton(Sender: TObject);
    procedure isaretlebutton(Sender: TObject);
    procedure sagayaslabutton(Sender: TObject);
    procedure araccubugu(Sender: TObject);
    procedure Farklikaydetbutton(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure ToolBar1Click(Sender: TObject);
  private
    { Private declarations }
    dosyaismi: string;
    procedure dosyaismiver(const adi: String);
    procedure kaydetmeyionayla;
    procedure acilandosyadurumu(const acilandosyaadi: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.yenibutton(Sender: TObject);
begin
    kaydetmeyionayla;
    dosyaismiver('Yeni metin belgesi');
    sayfa.Lines.Clear;
end;

procedure TForm1.dosyaismiver(const adi: String);
begin
  dosyaismi := adi;
  caption := Format('%s - %s', [ExtractFileName(adi), Application.Title]);
end;

procedure TForm1.kaydetmeyionayla;
var
  secim: Integer;
begin
  secim :=Application.MessageBox('Dosyayı kaydetmek ister misiniz?','Kapatılıyor!',mb_yesnocancel);
  case secim of
    mrYes: kaydetbutton(Self);
    mrNo: {Nothing};
    mrCancel: Abort;
  end;
end;



procedure TForm1.acbutton(Sender: TObject);
begin
  kaydetmeyionayla;
  if OpenDialog.Execute then
  begin
    acilandosyadurumu(OpenDialog.FileName);
    sayfa.ReadOnly := ofReadOnly in OpenDialog.Options;
  end;
end;

procedure TForm1.acilandosyadurumu(const acilandosyaadi: string);
begin
  sayfa.Lines.LoadFromFile(acilandosyaadi);
  dosyaismiver(acilandosyaadi);
end;

procedure TForm1.kaydetbutton(Sender: TObject);
begin
  if dosyaismi = 'Yeni metin belgesi' then
    Farklikaydetbutton(Sender)
   else
    sayfa.Lines.SaveToFile(dosyaismi);
end;

procedure TForm1.duzengerialbutton(Sender: TObject);
begin
  with sayfa do
    if HandleAllocated then SendMessage(Handle, EM_UNDO, 0, 0);

end;

procedure TForm1.duzenkesbutton(Sender: TObject);
begin
       sayfa.CutToClipboard ;
end;

procedure TForm1.duzenkopyalabutton(Sender: TObject);
begin
      sayfa.CopyToClipboard;
end;

procedure TForm1.duzenyapistirbutton(Sender: TObject);
begin
    sayfa.PasteFromClipboard;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
      combobox1.Items:=screen.Fonts;
      combobox1.Text:=sayfa.Font.Name;
      dosyaismiver('Yeni metin belgesi');
end;

procedure TForm1.yaziboyutuChange(Sender: TObject);
begin
    sayfa.Font.Size:=StrToInt(yaziboyutu.Text);
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
    sayfa.Font.Name:=combobox1.Text;
end;


procedure TForm1.programcikis(Sender: TObject);
begin
    close;
end;

procedure TForm1.yazitipi(Sender: TObject);
begin
    FontDialog1.Execute;
    sayfa.Font :=FontDialog1.Font ;
    sayfa.Font.Size :=FontDialog1 .font.Size;
    sayfa.Font.Style:=FontDialog1 .Font.Style ;
    sayfa.Font.Color:=Fontdialog1 .Font.Color;
    yaziboyutu.Text :=inttostr(Fontdialog1.Font.size);
    combobox1.text:=fontdialog1.Font.Name;
end;

procedure TForm1.kalinbutton(Sender: TObject);
begin
    if kalin.Down then
        sayfa.Font.Style :=sayfa.font.style+[fsbold]
      else
        sayfa.font.style:=sayfa.font.style-[fsbold];
end;


procedure TForm1.italikbutton(Sender: TObject);
begin
     if italik.Down then
        sayfa.Font.Style :=sayfa.font.style+[fsItalic]
      else
        sayfa.font.style:=sayfa.font.style-[fsItalic];
end;

procedure TForm1.alticizgilibutton(Sender: TObject);
begin
      if alticizgili.Down then
        sayfa.Font.Style :=sayfa.font.style+[fsUnderline]
      else
        sayfa.font.style:=sayfa.font.style-[fsUnderline];
end;

procedure TForm1.solayaslabutton(Sender: TObject);
begin
      sayfa.Paragraph.Alignment := taLeftJustify
end;

procedure TForm1.ortalabutton(Sender: TObject);
begin
      sayfa.Paragraph.Alignment := tacenter;
end;

procedure TForm1.isaretlebutton(Sender: TObject);
begin
     sayfa.Paragraph.Numbering := TNumberingStyle(isaretle.Down);
end;

procedure TForm1.sagayaslabutton(Sender: TObject);
begin
     sayfa.Paragraph.Alignment :=taRightJustify;
end;

procedure TForm1.araccubugu(Sender: TObject);
begin
    if Araubuu1.Checked then
         toolbar1.Visible:=true
      else
         toolbar1.visible:=false;
end;

procedure TForm1.Farklikaydetbutton(Sender: TObject);
begin
    if SaveDialog.Execute then
       begin
         if FileExists(SaveDialog.FileName) then
            if application.Messagebox('Var olan dosya değiştirilsin mi?','Değiştir',mb_YesNoCancel) <> mrYes then Exit;
         sayfa.Lines.SaveToFile(SaveDialog.FileName);
         dosyaismiver(SaveDialog.FileName);
       end;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  kaydetmeyionayla;
end;

procedure TForm1.ToolBar1Click(Sender: TObject);
begin

end;

end.


Sayfa: [ 1 ]