title: HODISALARI - Информатика
text: HODISALARI
  OnActivate
  Aktiv bo`lganda
  OnClick
  Sichqoncha bosilganda
  OnClose
  Yopilganda
  OnCreate
  Yaratilganda
  OnDblClick
  Sichqoncha 2 marta bosilganda
  OnHide
  Yoshiringanda
  OnKeyPress
  Tugma bosilganga
  OnShow
  Chaqirilganda
  Formning qolgan xossa va hodisalar bilan keyinroq tanishamiz. Form bilan
  bitta misol ko`rib chiqaylik. Masalan, Oynaning sarlavhasida ―Birinchi oynam‖,
  ekranning o`rtasidan, oq rangli, balandligi 250, uzunligi 250 o`lchamda,
  yaratilganda ―Oyna yaratildi‖, yopilganda ―Oyna yopiladi‖, sichqoncha bir marta
  bosilsa, ―Sichqoncha bosildi‖, sichqoncha ikki marta bosilsa, ―Sichqoncha ikki
  marta bosildi‖ degan muloqot oynalarini chiqaruvchi oyna yaratishni olamiz.
  297
  C++ Builder dasturi ishga tushirilgan va bir loyiha tayorlangan bo`lsa, uni
  xotiraga olib (save all), so`ng barcha loyihalarni yopamiz (close all). Yangi loyiha
  yaratamiz (file->New Application).
  1.
  Form sarlavhasida yozish uchun Object Inspector oynasidan properties
  bo`limiga o`tib, caption ―Birinchi oynam‖ matnini yozamiz;
  2.
  Position ga o`tib, uni poScreenCenter ga tenglashtiramiz;
  3.
  Color ni oq rangni (clWindow) tanlaymiz;
  4.
  Height ning qiymatiga 250,Width ning qiymatiga 250 ni kiritamiz;
  5.
  Object Inspector oynasidan events bo`limiga o`tib, OnCreate o`ng tomoniga
  ikki marta sichqonchani bosib, void __fastcall TForm1:: FormCreate ( TObject
  *Sender ) protsedurasiga ShowMessage ( "Oyna yaratildi " ); matni kiritiladi.
  ShowMessage ekranda xabarlarni chiqaradi;
  6.
  OnClose o`ng tomoniga ikki marta sichqonchani bosib, void __fastcall TForm1
  :: FormClose ( TObject *Sender, TCloseAction &Action ) protsedurasiga
  ShowMessage ( " Oyna yopiladi " ); matnni kiritiladi;
  7.
  OnClick o`ng tomoniga ikki marta sichqonchani bosib, void __fastcall TForm1
  :: FormClick (TObject *Sender) protsedurasiga ShowMessage ("Sichqoncha
  bosildi" ); matnni kiritiladi;
  8.
  OnDblClick o`ng tomoniga ikki marta sichqonchani bosib, void __fastcall
  TForm1 :: FormDblClick (TObject *Sender) protsedurasiga ShowMessage
  ("Sichqoncha ikki marta bosildi"); matnni kiritiladi;
  Shunday qilib, berilgan vazifa bajarildi. [F9] tugmasi bosib, dasturni
  tekshiramiz va ishlatamiz. Yuqoridagi 1,2,3 va 4 larni operatorlar bilan kiritsa
  bo`ladi. Buning uchun Object Inspector oynasidan events bo`limiga o`tib,
  OnCreate o`ng tomoniga ikki marta sichqonchani bosib, void __fastcall TForm1::
  FormCreate ( TObject *Sender ) prosedurasiga quyidagi listing kiritiladi.
  6.3-listing
  Caption="Birinchi oynam";
  Position=poScreenCenter;
  298
  Color=clWindow;
  Height=250;
  Width=250;
  Bu misolning umumiy listing kodi quyidagicha:
  6.4-listing
  //---------------------------------------------------------------------------
  #include
  #pragma hdrstop
  #include "Unit1.h"
  //---------------------------------------------------------------------------
  #pragma package(smart_init)
  #pragma resource "*.dfm"
  TForm1 *Form1;
  //---------------------------------------------------------------------------
  __fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
  { }
  //---------------------------------------------------------------------------
  void __fastcall TForm1::FormCreate(TObject *Sender)
  { Caption="Birinchi oynam";
  Position=poScreenCenter;
  Color=clWindow;
  Height=250;
  Width=250;
  ShowMessage("oyna yaratildi"); }
  //---------------------------------------------------------------------------
  void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
  { ShowMessage("Oyna yopilladi") ; }
  299
  //---------------------------------------------------------------------------
  void __fastcall TForm1::FormClick(TObject *Sender)
  { ShowMessage("Sichqoncha bosildi");}
  //---------------------------------------------------------------------------
  void __fastcall TForm1::FormDblClick(TObject *Sender)
  { ShowMessage("Sichqoncha ikki marta bosildi"); }
  |