MUXAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI FARG`ONA FILIALI KOMPYUTER INJINERINGI FAKULTETI 611-21 GURUH TALABASI
ABDURASHIDOV ABDUXALILNING
DASTURLASH 2 FANIDAN TAYYORLAGAN DEDLAYNI
2-dedline. Bloknot dasturini tayyorlash.
Men Bloknot dasturini tayyorlash uchun C++ Builder dasturlash muhitining Rad Studio XE3 versiyasidan foydalandim. Bloknot yaratish uchun avval C++ Builderda yangi loyiha yaratamiz:
Bloknot dasturini interfeysini yaratib olamiz. Avval formaga MainMunu komponentasini menyular hosil qilish uchun joylashtiramiz:
So`ngra mainmenu komponentasiga turli xususiyatlar menyularini kiritamiz va u menyularga submenyularni kiritamiz :
Keyin imagelist komponentasini formaga joylaymiz va u komponenta tarkibiga rasmlarni yuklab olamiz:
Keyin MainMenu komponentasining menyulariga rasm yuklash uchun ImageIndex funksiyasidan foydalanamiz.
Dasturimizda ma’lumotlarni yozish uchun esa memo komponentasidan foydalanamiz. Uning shriftini o`zgartirish uchun Lines funksiyasidan foydalanamiz.
Shu tarzda dastur dizaynini quyidagi holatga keltiramiz :
Dastur dizayni tayyor bo`lgandan so`ng komponentalar ishlashi uchun bir qancha kodlar yozamiz. Va nixoyat bloknot dasturi tayyor holatga keladi.
Dasturning kod qismi:
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
AnsiString fileName = "Bloknot";
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Qaytasaqlash1Click(TObject *Sender)
{
if (SaveDialog1->Execute()) {
fileName = SaveDialog1->FileName + ".txt";
Memo1->Lines->SaveToFile(fileName );
Caption = ExtractFilePath(fileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Nuxsalash1Click(TObject *Sender)
{
Memo1->CopyToClipboard();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Qirqish1Click(TObject *Sender)
{
Memo1->CutToClipboard();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Joylashtirish1Click(TObject *Sender)
{
Memo1->PasteFromClipboard();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Barchasinibelgilash1Click(TObject *Sender)
{
Memo1->SelectAll();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Saqlash1Click(TObject *Sender)
{
if (fileName == "Bloknot") {
Qaytasaqlash1->Click();
} else {
Memo1->Lines->SaveToFile(fileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Ochish1Click(TObject *Sender)
{
if (!(Memo1->Text == "" && !Memo1->Modified)) {
int res = MessageDlg("Saqlaysimi?", mtInformation, TMsgDlgButtons()< if (res == mrYes) {
Saqlash1->Click();
if (OpenDialog1->Execute()) {
fileName = OpenDialog1->FileName;
Memo1->Lines->LoadFromFile(fileName) ;
Caption = ExtractFileName(fileName);
}
}else if (res == mrNo) {
if (OpenDialog1->Execute()) {
fileName = OpenDialog1->FileName;
Memo1->Lines->LoadFromFile(fileName) ;
Caption = ExtractFileName(fileName);
}
}
} else {
if (OpenDialog1->Execute()) {
fileName = OpenDialog1->FileName;
Memo1->Lines->LoadFromFile(fileName) ;
Caption = ExtractFileName(fileName);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Yangi1Click(TObject *Sender)
{
if (!(Memo1->Text == "" && !Memo1->Modified)) {
int res = MessageDlg("Saqlaysimi?", mtInformation, TMsgDlgButtons()< if (res == mrYes) {
Saqlash1->Click();
fileName = "Bloknot";
Caption = fileName;
Memo1->Clear();
}else if (res == mrNo) {
fileName = '' Bloknot";
Caption = fileName;
Memo1->Clear();
}
} else {
fileName = "Bloknot";
Caption = fileName;
Memo1->Clear();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Chopetish1Click(TObject *Sender)
{
if (PrintDialog1->Execute()) {
AnsiString temp;
if (fileName == "Bloknot"){
Memo1->Lines->SaveToFile("temp.txt");
temp = "temp.txt";
}
ShellExecuteA(Handle, "print", temp.c_str() , NULL,NULL,NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Chiqish1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
if (!(Memo1->Text == "" && !Memo1->Modified)) {
int res = MessageDlg("Saqlaysimi?", mtInformation, TMsgDlgButtons()< if (res == mrYes) {
Saqlash1->Click();
}else if (res == mrCancel) {
Abort();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Shirft2Click(TObject *Sender)
{
if (PrintDialog1->Execute()){
Memo1->Font = FontDialog1->Font;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Dasturhaqida1Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Yordam2Click(TObject *Sender)
{
}
//-------------------------------------------------------------------------
Do'stlaringiz bilan baham: |