Mirsaid Aripov, Nurillo Otaxanov


Listing 20.2. DemoMouse  loyihasi bosh forma moduli



Download 9,81 Mb.
bet192/209
Sana16.01.2022
Hajmi9,81 Mb.
#371485
1   ...   188   189   190   191   192   193   194   195   ...   209
Bog'liq
DELPHI dasturlash titli 2018

Listing 20.2. DemoMouse  loyihasi bosh forma moduli

unit Main; 

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls;

type

TMainForm = class(TForm) ColorDlg: TColorDialog; 

StatusBar: TStatusBar; Timer: TTimer;

  procedure FormMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);



procedure FormMouseUp (Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);

procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

procedure TimerTimer(Sender: TObject);

 private



MouseRect: TRect;

IsDown: Boolean;

RectColor: TColor;

 public



{ Public declarations }

 end;



var MainForm: TMainForm;

implementation {$R *.DFM}

procedure TMainForm.FormMouseDown (Sender: TObject;

Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

begin

if Button = mbLeft then with MouseRect do begin

IsDown := True; Left := X; Top := Y; Right := X; Bottom := Y;

Canvas.Pen.Color := RectColor; 

end;

if (Button = mbRight) and ColorDlg.Execute then

RectColor := ColorDlg.Color;

 end;



procedure TMainForm.FormMouseUp(Sender: TObject;

Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

begin

IsDown := False;

Canvas.Pen.Color := Color;

with MouseRect do

Canvas.Polyline([Point(Left, Top), Point(Right, Top),

Point(Right, Bottom), Point(Left, Bottom), Point(Left, Top)]);

with StatusBar do

begin

Panels[4].Text := ''; Panels [5] .Text := ";

 end;

 end;

procedure TMainForm.FonnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

 begin



with StatusBar do

 begin



Panels[2].Text := 'X: ' + IntToStr(X);

Panels[3].Text := 'Y: ' + IntToStr(Y);

 end;



if Not IsDown then Exit; Canvas.Pen.Color := Color;

with mouserect do begin

Canvas.Polyline([Point(Left, Top), Point(Right, Top),

Point(Right, Bottom), Point(Left, Bottom), Point(Left, Top)]);

Right := X;

Bottom := Y;

Canvas.Pen.Color := RectColor;

Canvas.Polyline([Point(Left, Top), Point(Right, Top),

Point(Right, Bottom), Point(Left, Bottom), Point(Left, Top)]);

 end;



with StatusBar do begin

Panels [4] .Text := 'Kenglik: ' + IntToStr

(Abs(MouseRect.Right - MouseRect.Left));

Panels[5].Text := 'Balandlik: ' +

IntToStr(Abs(MouseRect.Bottom - MouseRect.Top));

end;

end;

procedure TMainForm.TimerTimer(Sender: TObject); 

begin

with StatusBar do 

begin

Panels[0].Text := 'Sana: ' + DateToStr(Now);

Panels[1].Text := 'Baqt: ' + TimeToStr(Now);

 end; 



end;

end.

Sichqonchaning chap tugmasi chertilganda FormMouseDown metodida to`rtburchak chizish rejimi (isDown := True) ishga tushadi va uning boshlang’ich koordinatalari aniqlanadi.

Sichqoncha forma bo`ylab “yurganda” FormMouseMove metodi ishga tushadi va ko`rsatkichning koordinata va o`lchamlari holatlar paneliga uzatiladi. Agar sichqonchaning chap tugmasi bosilgan (isDown:=True) bo`lsa, u holda to`rtburchak qayta chiziladi.

Sichqoncha tugmasi qo`yib yuborilganda (isDown:=False) FormMouseUp metodi to`rtburchak chizish jarayonini to`xtatadi.

Agar sichqonchaning o`ng tugmasi bosilgan bo`lsa, FormMouseDown metodi rang tanlash oynasini ekranga chiqaradi va to`rtburchak chiziqlari rangini o`zgartirish imkoni paydo bo`ladi.

TimerTimer metodi xolatlar panelida joriy vaqt va sanani ko`rsatadi.


Download 9,81 Mb.

Do'stlaringiz bilan baham:
1   ...   188   189   190   191   192   193   194   195   ...   209




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish