: ,
: DELPHI
: ,
: 2 .
:
1. .. Delphi. : . 49-51, 400-483.
2. .. Delphi 7. . .: , 2008. . 151-182.
3. .., .., .. Delphi. . .: , 2007. . 10-48, 72-90.
4. .. Delphi : . .: , 2006. . 15-102.
:
1. Win32, , , .
2. System, Dialogs Samples, , , .
Delphi , . ― TImage (TDBImage), TShape, TBevel.
TImage . - Additional . Picture ( ). BMP (bitmap), WMF (Windows Meta File) ICO (icon). (TDBImage , BLOB. BMP.)
TShape ― , .. Shape. Pen . Brush . , .
TBevel ― , . TPanel, . Shape Style.
Canvas
Canvas (), . - TBitmap, TComboBox, TDBComboBox, TDBGrid, TDBListBox, TDirectoryListBox, TDrawGrid, TFileListBox, TForm, TImage, TListBox, TOutline, TPaintBox, TPrinter, TStringGrid. Canvas , , (Pen), (Brush) (Font). Canvas : Draw, TextOut, Arc, Rectangle .
Canvas:
Brush ― , :
Bitmap ― 8x8, () .
Color ― .
Style ― ; Bitmap ― , .
|
|
Handle ― Windows API.
ClipRect ― ( ) , .
CopyMode ― , ( CopyRect) : , .
Font ― , ( TextOut).
Handle ― Windows API.
Pen ― , ; (Brush) :
Color ―
Handle ― Windows API
Mode ― : , , .
Style ― : , .
Width ―
PenPos ― , MoveTo, .
Pixels ― (pixel), .
Canvas:
― Arc, Chord, LineTo, Pie, Polygon, PolyLine, Rectangle, RoundRect. (Pen) , - (Brush).
― Draw StretchDraw, ( TBitmap, TIcon TMetafile). StretchDraw , , .
― TextOut TextRect. (Font) . TextRect . TextWidth TextHeight.
TPaintBox
System TPaintBox, , , (, , ). , Canvas, TPaintBox , , . , , (OnMouseMove .), , .. TPaintBox, .
:
private
slBitMap: TSringList;
. OnCreate OnDestroy . : Bmp_Path . , , .
|
|
( ), OnGet-EditText. slBitMap, , . , OnSetEditText slBitMap . OnDrawCell TDrawGrid, - / .
, OnResize ( ). () () 1 . (. 32.1).
32.1 ―
Align | alClient | |
ColCount | 2 | |
FixedCols | ||
FixedRows | ||
Name | dgDraw | |
Options.goEditing | True | |
RowCount | 2 | |
ScrollBars | sbNone |
procedure TTfmDrawGrid.dgDrawGridGetEditText(Sender: TObject; ACol, ARow: Integer; var Value: string);
// ,
begin
Value:= slBitMap[2 * ACol + Arow]
end;
procedure TTfmDrawGrid.dgDrawGridSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string);
// slBitMap
begin
slBitMap[2 * ACol + ARow]:= Value
end;
procedure TTfmDrawGrid.FormCreate(Sender: TObject);
const
FNames: array [0..3] of String = ('c:\bmp1.bmp', 'c:\bmp2.bmp', 'c:\bmp3.bmp', 'c:\bmp4.bmp');
Var k: Integer;
begin
// :
slbitmap:= TStringList.Create;
// :
with slbitmap do for k:= 0 to 3 do
begin
Add (FNames [k]);
Objects [k]:= TBitMap.Create;
(Objects[k] as TBitMap).LoadFromFile (FNames[k])
end;
procedure TTfmDrawGrid.FormDeactivate(Sender: TObject);
begin // slBitMap
slBitMap.Free
end;
procedure TTfmDrawGrid.FormResize(Sender: TObject);
// .
//
begin
with dgDrawGrid do
begin
DefaultColWidth:= ClientRect.Right div 2 - 1; DefaultRowHeight:= ClientRect.Bottom div 2-1
end;
end;
procedure TTfmDrawGrid.dgDrawGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
// slBitMap.Objects slBitMap
Var k: Integer;
begin
k:= 2 * ACol + ARow;
with dgDrawGrid.Canvas, Rect, slBitMap do begin
// :
Bottom:= Bottom - TextHeight('1') -2;
// :
StretchDraw(Rect, (Objects[k] as TBitMap));
// :
TextOut(Left+(Right-Left-TextWidth(slBitMap[k])) div 2, Bottom + 1, slBitMap [k])
end // with dgDraw.Canvas, Rect, slBitMap do
end;
: 22 *.bmp.
:
Canvas .
Standard, Additional, Win32, System, Dialogs Samples, , , .