linkedin facebook linkedin facebook nod32

Delphi dasturlash tilida matn muxarrir yaratish

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2015-01-02

Delphi dasturlash tilida matn muxarrir yaratish .

Xar bir dasturni kritish uchun formga jixozli paneldan tugmachalarni joylashtirib chiqamiz xar bir tugmacha uchun Unit1.pas dasturlash kismida dasturini kritamiz. Jixozli panelda Dialogs bo`limida 10 elementli tugmacha kursatilgan xar bir tugmacha Macrosoft Word 7.0 versiyaыsida standart bo`limida uchraydi. Delphi7 dasturlash tilida menyuni quyidagicha yartamiz. Jixozli panelda Standart bo`limidan MainMenu1 tugmacha formga kuyiladi kuyilgan tugmacha sichkoncha chap tugmasi ikki marta bosiladi natijada kuyidagi xasil bo’ladi rasm1.

rasm 1.

Ob’ektni uzgartirish Properties bo`limida Caption dan menyuga so’zlar kritib chiqiladi rasm2.

rasm 2.

Xar bir menyu uchun dasturni kritish jixozli paneldan formga tugmachalarni joylashtirib chiqamiz xar bir tugmacha uchun Unit1.pas dasturlash kismida dasturini kritamiz. Jixozli panelda Dialogs bo`limida 10 elementli tugmacha kursatilgan xar bir tugmacha Macrosoft Word 7.0 versiyasida menyu bo`limida uchraydi rasm3.'

rasm 3.

Ob’ektni kursatish OpenDialog1 kursorni qo’ygan xolatda Properties bo`limida Filter sichqoncha tugmasi bilan tanlanadi rasm4.

rasm 4.

Faylni filtirlash (Filter Editor) xujatli faylni filtirlash uchun muljallangan. Fayl nomi (Filter Name) ochish tanlanganda faylning kengaytkichini tanlaydi va tipini kursatadi. Filtirlash (Filter) kursatilgan kengaytkichni ochadi.

Loyhalashtirilgan darchani yaratib olamiz

rasm 5.

Menyuning ochish qismining dasturi quyidagicha bo’ladi.

procedure TForm1.N2Click(Sender: TObject);
begin
OpenDialog1.Title:=’Hujjatni saqlash ’;
IF OpenDialog1.Execute Then
richEdit1.Lines.LoadFromFile(OpenDialog1.filename);
end;

Menyuning saqlash qismining dasturi quyidagicha bo’ladi.

procedure TForm1.N3Click(Sender: TObject);
begin
SaveDialog1.Title:=’Hujjatni saqlash’;
IF SaveDialog1.Execute then RichEdit1.Lines.SaveToFile(SaveDialog1.filename);
end;

 

Menyuning yopish qismining dasturi quyidagicha bo’ladi.

procedure TForm1.N5Click(Sender: TObject);
begin
Close;
end;
Form Form1 ob’ekni uzgartirish Events bo`limida OnCloseQuery tanlanadi dasturi quyidagicha kurinishda bo’ladi.

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
SaveDialog1.Title:='Saqlash';
case MessageDlg('CHikishdan oldin xujjatni saqlashni xoxlaysizma?', mtCustom, [mbYes, mbNo,mbCancel], 0 ) of
mrCancel: CanClose:=False;
mrYes : begin if SaveDialog1.Execute then richedit1.Lines.SaveToFile(SaveDialog1.FileName); Application.Terminate end;
mrNo : Application.Terminate;
end;

Menyuning nusxa olish dasturi quyidagicha bo’ladi.

procedure TForm1.N6Click(Sender: TObject);
begin
RichEdit1.CopyToClipboard;
end;

Menyuning nusxa kuyish dasturi quyidagicha bo’ladi.

procedure TForm1.N7Click(Sender: TObject);
begin
RichEdit1.PasteFromClipboard;
end;
Menyuning nusxa kirkish dasturi quyidagicha bo’ladi.

procedure TForm1.N8Click(Sender: TObject);
begin
RichEdit1.CutToClipboard;
end;

Menyuning rang uzgartirish dasturi quyidagicha bo’ladi.

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

Menyuning xarf uzgartirish dasturi quyidagicha bo’ladi.

procedure TForm1.N11Click(Sender: TObject);
begin
If FontDialog1.Execute then
RichEdit1.Font:=FontDialog1.Font;
end;

Menyuning izlash dasturi quyidagicha bo’ladi.

procedure TForm1.N12Click(Sender: TObject);
begin
FindDialog1.Execute;
if Pos(FindDialog1.FindText,richedit1.Text)<>0 then
with richedit1 do
begin
HideSelection:=False;
SelStart:=Pos(FindDialog1.FindText, richedit1.Text)-1;
SelLength:=Length(FindDialog1.FindText);
end else ShowMessage('Ñàòð'+FindDialog1.FindText+' òîïèëìàäè');

end;

Menyuning almashtirish dasturi quyidagicha bo’ladi.

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

Ob’ektni uzgartirish Events bo`limidan OnReplace tanlanadi.

procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
begin
label 10;
begin
10:
if Pos(replaceDialog1.FindText,richedit1.Text)<>0 then
with richedit1 do
begin
SelStart:=Pos(ReplaceDialog1.FindText, richedit1.Text)-1;
SelLength:=Length(ReplaceDialog1.FindText);
SelText:=ReplaceDialog1.FindText;
goto 10;
HideSelection:=False;
end else ShowMessage(ReplaceDialog1.FindText+' topilmadi');
end;

 

Darchani kattalashtirish natijasida form xam birgalikda kattarishi uchun ob’ekni uzgartirish Events bo`limida OnCanResize tanlandi . Dastur quyidagicha bo’ladi.

procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
if (NewWidth<570)or(NewHeight<=460) then Resize:=false else
begin
Richedit1.Height:=Height-180;
Richedit1.Width:=Width-40;
end;
end;

Yozuv darchaning dasturi quyidagicha bo’ladi rasm6.

rasm 6.

Dastur matni qudagicha keltirilgan

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, Menus, StdCtrls, ComCtrls;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PrintDialog1: TPrintDialog;
FindDialog1: TFindDialog;
ReplaceDialog1: TReplaceDialog;
RichEdit1: TRichEdit;
StatusBar1: TStatusBar;
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure N6Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure ReplaceDialog1Replace(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.N2Click(Sender: TObject);
begin
OpenDialog1.Title:='Ochish'; {Titilni Ochish deb uzgartiradi}
IF OpenDialog1.Execute Then {Titilni kursatadi}
richEdit1.Lines.LoadFromFile(OpenDialog1.filename); {Titilda kursatilgan faylni ochadi}
end;

procedure TForm1.N3Click(Sender: TObject);
begin
SaveDialog1.Title:='Saqlash'; {Titilni saqlash deb uzlashtiradi}
IF SaveDialog1.Execute then {Titilni Saqlash tugmachasiga uzlashtiradi}
RichEdit1.Lines.SaveToFile(SaveDialog1.filename); {Berilgan teksni saklaydi}

end;

procedure TForm1.N4Click(Sender: TObject);
begin
PrintDialog1.Execute;

end;

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

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
SaveDialog1.Title:='Saqlash';
case MessageDlg('CHikishdan oldin xujjatni saqlashni xoxlaysizma?', mtCustom, [mbYes, mbNo,mbCancel], 0 ) of
mrCancel: CanClose:=False;
mrYes : begin if SaveDialog1.Execute then richedit1.Lines.SaveToFile(SaveDialog1.FileName); Application.Terminate end;
mrNo : Application.Terminate;

end;
end;
procedure TForm1.N6Click(Sender: TObject);
begin
RichEdit1.CopyToClipboard;
end;

procedure TForm1.N7Click(Sender: TObject);
begin
RichEdit1.PasteFromClipboard;
end;

procedure TForm1.N8Click(Sender: TObject);
begin
RichEdit1.CutToClipboard;
end;

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

procedure TForm1.N11Click(Sender: TObject);
begin
If FontDialog1.Execute then
RichEdit1.Font:=FontDialog1.Font;
end;

procedure TForm1.N12Click(Sender: TObject);
begin
FindDialog1.Execute;
if Pos(FindDialog1.FindText,richedit1.Text)<>0 then
with richedit1 do
begin
HideSelection:=False;
SelStart:=Pos(FindDialog1.FindText, richedit1.Text)-1;
SelLength:=Length(FindDialog1.FindText);
end else ShowMessage('Satr'+FindDialog1.FindText+' topilmadi');

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

procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
label 10;
begin
10:
if Pos(replaceDialog1.FindText,richedit1.Text)<>0 then
with richedit1 do
begin
SelStart:=Pos(ReplaceDialog1.FindText, richedit1.Text)-1;
SelLength:=Length(ReplaceDialog1.FindText);
SelText:=ReplaceDialog1.FindText;
goto 10;
HideSelection:=False;
end else ShowMessage(ReplaceDialog1.FindText+' topilmadi');
end;

 

procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
if (NewWidth<570)or(NewHeight<=460) then Resize:=false else
begin
Richedit1.Height:=Height-180;
Richedit1.Width:=Width-40;
end;
end;

end.

1225 marta o`qildi.

Foydalanuvchi ismi: 101-Humoyiddin
Qo`shilgan sana: 2015-04-10

yaxshi

Foydalanuvchi ismi: Rivoj 203
Qo`shilgan sana: 2015-04-16

ajoyib

Foydalanuvchi ismi: Eshboyev Quvonchbek 203
Qo`shilgan sana: 2015-04-17

ajoyib

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений