.


:




:

































 

 

 

 


. Windows (Device Context)




Windows (Device Context). Windows- , , . C++ Builder : TCanvas ( ), TBrush ( ), TPen ( ), TFont ( ). ᒺ : Canvas, Brush, Pen, Font, Brush, Pen Font Canvas.

Canvas (, ) , .

Pen () , ( ).

Brush () . , .

Font , . TextOut Canvas.

Canvas ᒺ. Canvas .

- , Form1. , , , PaintBox ( System).

, , Canvas, Brush, Pen, Font, 䳿 OnPaint. . TCanvas.

, Canvas, TPanel.

(TPen), (TBrush), (TFont) (TCanvas).

TPen:

Color (, , - , F1);

Width ;

Style ( 1 ). Style .:

 

Mode , , . TColor. ϳ and, or, not, xor. Mode:

  • pmCopy - - .
  • pmNotCopy - ( not) .
  • pmNot - .
  • pmXor - xor .
  • pmNotXor - pmXor, not-.
  • pmMask - and .
  • pmNotMask - pmMask, pmNot.
  • pmMerge - or .
  • pmNotMerge - pmMerge.
  • pmNop - .
  • pmBlack - .
  • pmWhite - .

 

TBrush:

Color ;

Style ( ):

bsBDiagonal bsDiagCross
bsFDiagonal bsHorizontal
bsCross bsVertical

Bitmap , . TBrush Style .

 

TFont:

Color ;

Size ;

Name ;

Style , : fsBold , fsItalic , fsUnderline , fsStrikeOut .

 

TCanvas:

Font ᒺ-;

Pen ᒺ-;

Brush ᒺ-;

PenPos .

Pixels[X,Y] TColor ( ). , .

 

TCanvas:

MoveTo(X,Y) (X,Y) ;

LineTo(X,Y) (X,Y);

Rectangle(X1,Y1,X2,Y2) . , .

:

Canvas->Pen->Color=clMaroon;

Canvas->Brush->Color=clYellow;

Canvas->Rectangle(50,50,200,100);

 

Ellipse(X1,Y1,X2,Y2) , ;

Arc(X1,Y1,X2,Y2, X3,Y3,X4,Y4) , (X1,Y1)(X2,Y2). , , (X3,Y3), , (X4,Y4);

Poligon(points, count) , points ( TPoint), count . ʳ , . TPoint :

struct TPoint

{

int x;

int y;

};

1 . .

TPoint points[4];

points[0].x=50; points[0].y=50;

points[1].x=150; points[1].y=50;

points[2].x=75; points[2].y=150;

points[3].x=50; points[3].y=150;

Canvas->Polygon(points,3);

 

Poliline(points, count) , points.

:

const MAX_LINES=6;

TPoint lines[MAX_LINES];

for(int i=0;i<MAX_LINES; i++)

{ lines[i].x=random(ClientWidth);

lines[i].y=random(ClientHeight);

};

Canvas->MoveTo(random(ClientWidth),random(ClientHeight));

Canvas->Polyline(lines,MAX_LINES-1);

 

Refresh() , ;

TextOut(X, Y, Text) Text , , (X,Y).

TextExtent(Text) TSize , Text.

typedef struct TSize

{

long cx;

long cy;

}

TSize __fastcall TextExtent(const AnsiString Text);

 

FloodFill(X,Y, Color, FillStyle) . (X,Y). FillStyle =fsSurface, Color. FillStyle =fsBorder, Color, Color .

 

FillRect(X1,Y1,X2,Y2) .

 

FrameRect(X1,Y1,X2,Y2) ( ).





:


: 2015-10-01; !; : 604 |


:

:

- - , .
==> ...

1888 - | 1839 -


© 2015-2024 lektsii.org - -

: 0.014 .