版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Graphics 單元中的類 /Graphics 單元中的類 TGraphicsObjectTFo ntTPe nTBrushTFo ntRecallTPe nRecallTBrushRecallTCa nvasTGraphicTPictureTMetafileCa nvasTMetafilelmageTMetafileTBitmapImageTBitmapTIc onl mageTIc onTResourceMa nagerTBrushResourceMa nager TFileFormatsList的類成員Delphi 的繪圖功能1- TCanvas/過程:ArcBrushCopy Cho
2、rdCopyRectDrawDrawFocusRectEllipseEllipseFillRectFloodFillFrameRectLin eToLock MoveToPiePolyg on Polyli ne PolyBezier PolyBezierTo Recta ngle Recta ngle RefreshRou ndRect StretchDraw TextOut TextRect TextRectUn lock/函數(shù):Han dleAllocatedTextExte ntTextHeightTextWidthTryLock/屬性:ClipRectHan dleLockCo un
3、tCanv asOrie ntati onPenPosPixelsTextFlagsBrushCopyModeFontPen/事件OnChangeOn Cha ngingDelphi 的繪圖功能2-入門繪圖需要有紙、畫筆、畫刷 ;Delphi有 Canvas、Pen、Brush.Canvas就是畫布,譬如窗體的 Canvas屬性,就是窗體的畫布Pen是畫筆,可以設(shè)置筆色、筆寬等等;Brush是畫刷,可以設(shè)置顏色等等./舉例:繪制直線procedure TForm1 . Butt on 1Click(Se nder: TObject);begi nCanvas.Pen. Color := clR
4、ed;設(shè)置畫筆顏色Canvas.Pen. Width :=2;設(shè)置畫筆寬度Canvas.MoveTo( 10, 10);直線起點(diǎn)Canvas.LineTo( 100 , 100);直線終點(diǎn)這里的Canvas 是簡(jiǎn)寫,也可以寫做:Self.Canvas或Form1.Canvas end;矩形填充procedure TForm1 . Butt on 2Click(Se nder: TObject);begi nCanvas . Brush . Color := clYellow;設(shè)置畫刷顏色,也就是填充色Canvas . FillRect(ClientRect);填充窗體客戶區(qū)end;/效果圖:D
5、elphi 的繪圖功能3-矩形類圖形un it Un itl;in terfaceusesWin dows. Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForm1 = class (TForm)Button1: TButton;Butto n2: TButt on;Butto n3: TButt on;Butto n4: TButt on;Butto n5: TButt on;procedure FormCreate(Se nder: TObject);pr
6、ocedureButt on 1Click(Se nder: TObject);procedureButt on 2Click(Se nder: TObject);procedureButt on 3Click(Se nder: TObject);procedureButt on 4Click(Se nder: TObject);procedureButt on 5Click(Se nder: TObject);end;varForm1: TForm1;impleme ntati on$R *dfmvarbtn: TButton;con sty1 =10;y2 =80;先設(shè)置畫筆畫刷proce
7、dure TForml . FormCreate(Sender: TObject);begi nCanvas . Pen. Width :=4;Canvas . Pen. Color := clRed;Canvas . Brush . Color := clWhite;end;給出左上角和右下角的坐標(biāo)就可以繪制矩形procedure TForm1 . Butt on 1Click(Se nder: TObject);begi nbtn := TButto n(Se nder);Ca nvas . Recta ngle(bt n.Left, y1, btn . Left+btn . Width,
8、 y2);end;給出一個(gè)矩形結(jié)構(gòu)做參數(shù)也可以繪制矩形procedure TForml . Butt on 2Click(Se nder: TObject);varR: TRect;定義一個(gè)矩形結(jié)構(gòu)begi nbtn := TButto n(Se nder);R := Rect(btn . Left, y1, btn .Left+btn . Width, y2);Canvas . Rectangle(R);end;繪制圓角矩形;最后兩個(gè)參數(shù)是設(shè)置圓角的procedure TForml . Butt on 3Click(Se nder: TObject);begi nbtn := TButto
9、n(Se nder);Can vas . Rou ndRect(bt n.Left, y1, btn .Left+btn . Width, y2,20, 20);end;繪制焦點(diǎn)矩形;它不受畫筆的影響;它的顏色是和畫刷的顏色進(jìn)行某種運(yùn)算得來的procedure TForml . Butt on 4Click(Se nder: TObject);varR: TRect;begi nbtn := TButto n(Se nder);R := Rect(btn . Left, y1, btn .Left+btn . Width, y2);Canvas . DrawFocusRect(R);end;矩
10、形描邊,用的不是畫筆是畫刷 procedure TForml . Butt on 5Click(Se nder: TObject);varR: TRect;begi nbtn := TButto n(Se nder);.Left+btn . Width, y2);R := Rect(btn . Left, y1, btnCanvas . FrameRect(R);end;end./效果圖:ForslGutton4Delphi 的繪圖功能4-圓弧類圖形un it Un itl;in terfaceusesWin dows, Messages, SysUtils, Varia nts. Class
11、es, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForml = class (TForm)Button1: TButton;Butto n2: TButt on;Butto n3: TButt on;Butto n4: TButt on;Butto n5: TButt on;procedureFormCreate(Se nder: TObject);procedureButt on 1Click(Se nder: TObject);procedureButt on 2Click(Se nder: TObject);procedureB
12、utt on 3Click(Se nder: TObject);procedureButt on 4Click(Se nder: TObject);procedureButt on 5Click(Se nder: TObject);end;varForm1: TForm1;impleme ntati on$R *dfmvarbtn: TButt on;con sty1 =10;y2 =80;先設(shè)置畫筆畫刷procedure TForml . FormCreate(Sender: TObject);begi nCanvas . Pen. Width :=2;Canvas . Pen. Color
13、 := clRed;Canvas . Brush . Color := clWhite;end;繪制橢圓;橢圓的參數(shù)和矩形是一樣的procedure TForml . Butt on 1Click(Se nder: TObject);begi nbtn := TButto n(Se nder);Canvas . Ellipse(btn. Left, y1, btn . Left+btn . Width, y2);end;根據(jù)矩形結(jié)構(gòu)繪制橢圓procedure TForml . Butt on 2Click(Se nder: TObject);varR: TRect;定義一個(gè)矩形結(jié)構(gòu)begi n
14、btn := TButto n(Se nder);R := Rect(btn . Left, y1, btn . Left+btn . Width, y2);Canvas . Ellipse(R);end;繪制扇形procedure TForml . Butt on 3Click(Se nder: TObject); begi nbtn := TButto n(Se nder);Canvas . Pie(btn.Left, y1,矩形區(qū)域左上角btn.Left + btn.Width, y2,矩形區(qū)域右下角btn.Left + btn.Width, y1 + (y2-y1)div 2, 扇形起
15、點(diǎn)btn.Left + btn.Width div 2, y1扇形終點(diǎn));end;繪制弦,參數(shù)同上procedure TForm1 . Butt on 4Click(Se nder: TObject);begi nbtn := TButto n(Se nder);Canvas.Chord(btn .Left, y1,btn .Left + btn.Width, y2,btn .Left + btn.Width, y1 + (y2-y1)div 2btn .Left + btn.Width div 2, y1);end;繪制弧線,參數(shù)同上procedure TForm1 . Butt on 5C
16、lick(Se nder: TObject);begi nbtn := TButto n(Se nder);Canvas.Arc(btn .Left, y1,btn .Left + btn.Width, y2,btn .Left + btn.Width, y1 + (y2-y1)div 2btn .Left + btn.Width div 2, y1);end;end./效果圖:Delphi 的繪圖功能5-獲取 Canvas對(duì)象在窗體上添加 Panell、PaintBoxI和Button1,代碼如下:procedure TForm1 . Butt on 1Click(Se nder: TObj
17、ect);varcvs: TCanv as;begi nPaintBox1就像窗體一樣,也有Canvas 屬性PaintBox1. Canvas . Brush . Color := clRed;PaintBox1. Canvas . FillRect(PaintBox1. ClientRect);像Panel1這樣沒有Canvas 屬性的控件,也可以繞道獲取cvs := TCanvas. Create;cvs.Handle := GetDC(Panel1.Handle)cvs.Brush . Color := clBlue;cvs.FillRect(Panel1. ClientRect);c
18、vs.Free;end;/執(zhí)行前后對(duì)比圖Delphi 的繪圖功能6- Polygon 、Polylineun it Un itl;in terfaceusesWin dows. Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForm1 = class (TForm)Button1: TButton;Butto n2: TButt on;procedureFormCreate(Se nder: TObject);procedureButt on 1Click(Se
19、 nder: TObject);procedureButt on 2Click(Se nder: TObject);end;varForm1: TForm1;impleme ntati on$R *dfmprocedure TForm1 . FormCreate(Sender: TObject);begi nCanvas . Pen. Width :=2;Canvas . Pen. Color := clRed;Canvas . Brush . Color := clYellow;end;繪制多邊形;它的參數(shù)是一個(gè)點(diǎn)數(shù)組,這里定義了一個(gè)常數(shù)數(shù)組procedure TForm1 . Butt o
20、n 1Click(Se nder: TObject);con stpts:array 0.3 of TPoint =(x:10; y:40),(x:46; y:120),(x:82; y:40),(x:);46; y:10)丿,begi nCanvas . Polygon(pts);end;繪制連續(xù)的一組直線;它的參數(shù)也是一個(gè)點(diǎn)數(shù)組,我只是把上面的平移了一點(diǎn)procedure TForml . Butt on 2Click(Se nder: TObject);con stpts:array 0.3 of TPoint =(x:10+82; y:40),(x:46+82; y:120),(x:8
21、2+82; y:40),(x:46+82; y:10);begi nCanvas . Polyline(pts);end;end./效果圖:Delphi的繪圖功能7- PolyBezier 、PolyBezierToun it Un it1; in terface usesWin dows, Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForml = class (TForm)Butto n1: TButt on;Butto n2: TButt on;proc
22、edureButt on 1Click(Se nder: TObject);procedureButt on 2Click(Se nder: TObject);end;varForm1: TForm1;impleme ntati on$R *dfmPolyBezier至少需要四個(gè)點(diǎn)做參數(shù);不改變畫筆的當(dāng)前位置procedure TForm1 . Butt on 1Click(Se nder: TObject);varpts:array 0.3 of TPoint;begi nCanvas . Pen. Width :=2;Canvas . Pen. Color := clRed;pts0.X
23、:=10; pts0.Y :=10;起點(diǎn)pts1.X :=60; pts1.Y :=10;控制點(diǎn)1pts2.X :=10; pts2.Y :=100 ;控制點(diǎn)2pts3.X :=60; pts3.Y :=100 ;終點(diǎn)Canvas . PolyBezier(pts);Canvas.Pen.Width :=1;Canvas.Pen.Color := clWhite;Canvas.LineTo(ClientWidth, ClientHeight);end;會(huì)改變畫筆的當(dāng)前位置PolyBezierTo最少只需要需要三個(gè)點(diǎn),它把當(dāng)前位置當(dāng)作第一點(diǎn);procedure TForm1 . Butt on
24、2Click(Se nder: TObject);varpts:array 1.3 of TPoint;從 1 開始的,就 3 個(gè)元素begi nCanvas . Pen. Width :=2;Canvas . Pen. Color := cIRed;Canvas . MoveTo( 10 + 82, 10);起點(diǎn)pts0.X := 10; pts0.Y := 10;pts1.X :=60 +82; pts1.Y :=10;控制點(diǎn)1pts2.X :=10 +82; pts2.Y :=100;控制點(diǎn)2pts3.X :=60 +82; pts3.Y :=100;終點(diǎn)Canvas . PolyBez
25、ierTo(pts);Canvas . Pen. Width :=1;Canvas . Pen. Color := clBlue;Canvas . LineTo(ClientWidth, ClientHeight); end; end./效果圖:/繪制多條貝塞爾線時(shí),每條線的終點(diǎn)也是下條線的起點(diǎn)un it Un it1;in terfaceusesWin dows, Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForm1 = class (TForm)Butt
26、on1: TButton;Butto n2: TButt on;procedureButt on 1Click(Se nder: TObject);procedureButt on 2Click(Se nder: TObject);end;varForml: TForml;impleme ntati on$R *dfmPolyBezier繪制多條線時(shí),需要3*x + 1 個(gè)點(diǎn)procedure TForm1 . Butt on 1Click(Se nder: TObject); varpts:array 0.6 of TPoint;begi nCanvas . Pen.Width :=2;Ca
27、nvas . Pen.Color := clRed;pts0.X :=10; pts0.Y :=10;pts1.X :=60; pts1.Y :=10;pts2.X :=10; pts2.Y :=100 ;pts3.X :=40; pts3.Y :=100 ;pts4.X :=100; pts4.Y :=10;pts5.X :=55; pts5.Y :=99;pts6.X :=70; pts6.Y :=10;Canvas . PolyBezier(pts);end;PolyBezierTo 繪制多條線時(shí),需要3*x 個(gè)點(diǎn) procedure TForm1 . Butt on 2Click(Se
28、 nder: TObject); varpts:array 1.6 of TPoint;begi nCanvas . Pen. Width :=2;Canvas . Pen. Color := clRed;Canvas . MoveTo( 10 + 82, 10);pts0.X := 10; pts0.Y := 10;pts1.X :=60 +82; pts1.Y :=10;pts2.X :=10 +82; pts2.Y :=100;pts3.X :=40 +82; pts3.Y :=100;pts4.X :=100 +82 ; pts4.Y :=10;pts5.X :=55 +82; pts
29、5.Y :=99;pts6.X :=70 +82; pts6.Y :=10;Canvas . PolyBezierTo(pts);end./效果圖:睫 F咔P|IO_|fXDelphi的繪圖功能8- TextOut 、TextWidth 、TextHeightun it Un itl;in terfaceusesWin dows. Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForm1 = class (TForm)Button1: TButton;proce
30、dureButt on 1Click(Se nder: TObject);end;varForm1: TForm1;impleme ntati on$R *dfmprocedure TForm1 . Butt on 1Click(Se nder: TObject);con starr:array 0.3 of WideString =('白日依山盡','黃河入海流,'欲窮千里目,更上一層樓20; 橫向間隔b =20; 縱向間隔vars:string ;x,y: In teger;i,j: In teger;begi nx :=20;y :=20;for i :=
31、0 to Length(arr)- 1 dobegi nfor j :=1 to Length(arri)do j := 0 to Length(arri)-1 ? WideString!beg ins := arrij;Canvas . TextOut(x, y, s);x := x + Canvas. TextWidth(s) + a;end ;x :=20;y := y + Canvas . TextHeight(s) + b;end;end;end./效果圖:/第一種重載的聲明:TextRect(Rect: TRect;矩形X, Y: Integer;相對(duì)于窗體的位置const Tex
32、t: string 文本);如果要輸出的文本超出指定的矩形將不被顯示/第一種重載的舉例:procedure TForml . Butt on 1Click(Se nder: TObject);con stR: TRect = (Left:0; Top: 0; Right:60; Bottom: 60);s ='萬一的Delphi 博客'begi nCanvas . Brush . Color := clWhite;Canvas . FillRect(R);Canvas . TextRect(R, 10, 10, s);end;/效果圖:萬一的DeButton 1/第二種重載的聲
33、明TextRect(var Rect: TRect;矩形范圍var Text:string ;文本TextFormat: TTextFormat =選項(xiàng);集合類型,默認(rèn)值是個(gè)空的集合);參數(shù)三是TTextFormat類型的集合,它定義如下:TTextFormat =set of TTextFormats;TTextFormats是個(gè)枚舉,定義如下TTextFormats = (tfBottom, tfCalcRect, tfCe nter, tfEditCo ntrol, tfEn dEllipsi s,tfPathEllipsis, tfExpa ndTabs, tfExternalLead
34、i ng, tfLeft, tfModifyStri ng, tfNoClip, tfNoPrefix, tfRight, tfRtlReading, tfSingleLine, tfTop, tfVerticalCe nter, tfWordBreak);所以參數(shù)三可以是下列值之一或它們的組合tfBottomtfCalcRecttfCe ntertfEditCo ntroltfE ndEllipsistfPathEllipsistfExpa ndTabstfExter nalLead ingtfLefttfModifyStri ngtfNoCliptfNoPrefixtfRighttfRtl
35、Readi ngtfSi ngleLi netfToptfVerticalCe ntertfWordBreak/這個(gè)函數(shù)是API函數(shù)DrawTextEx 的簡(jiǎn)化,可以參見:DrawTextEx/第二種重載的舉例1: 默認(rèn)是頂對(duì)齊、左對(duì)齊;前兩個(gè)參數(shù)都是傳址的,不能用常量procedure TForm1 . FormPaint(Sender: TObject);varR: TRect;S: string ; begi nR := Clie ntRect;InflateRect(R,-10,- 10); 把矩形縮小一圈S := 'Delphi'Canvas.Brush . Colo
36、r := clWhite;Canvas.FillRect(R);Canvas.TextRect(R, S);end;/效果圖:單行文本、水平居中、垂直居中procedure TForm1 . FormPaint(Sender: TObject);varR: TRect;S: string ;begi nR := Clie ntRect;InflateRect(R,-10,- 10);把矩形縮小一圈S := 'Delphi' ;Canvas . Brush . Color := clWhite;Canvas . FillRect(R);Canvas . TextRect(R, S
37、 , tfSingleLine, tfCenter, tfVerticalCenter); end;/效果圖:Delphi 的繪圖功能10- TFONT 類/先來個(gè)例子:procedure TForml . FormPaint(Sender: TObject); con stS ='萬一的Delphi 博客'varfont: TFont;begi nfont := TFont.Create;fontName :='微軟雅黑:fontStyle :=fsBold, fsItalic;fontColor :=clRed;fontHeight :=72;Canvas.Font
38、:=fon t;Canvas.TextOut( 10, 10,fontFree;end;/效果圖:/因?yàn)镃anvas 的Font 屬性就是TFONT類的一個(gè)實(shí)例,所以上面的程序可以簡(jiǎn)化為procedure TForm1 . FormPaint(Sender: TObject);con stS ='萬一的Delphi 博客'begi nCanvas.Font.Name :='微軟雅黑:Canvas.Font.Style :=fsBold, fsItalic;Canvas.Font.Color :=clRed;Canvas.Font.Height :=72;Canvas.T
39、extOut( 10,10, S);end;/TFont類的常用屬性:Name:字體名稱Color:顏色Size、Height:字號(hào)與字體高度,都可以設(shè)定字體大小Style:字體樣式;是個(gè)集合值,是下面可選值或它們的組合:fsBoldfsItalicfsUn derli nefsStrikeOutPitch:是字間距相關(guān)的,有三個(gè)枚舉值可選(不過我沒測(cè)試出效果):fpDefaultfpVariablefpFixedCharset:字符集,是個(gè)整數(shù),可能的值有:ANSI_CHARSET =0;DEFAULT_CHARSET=1;SYMBOL_CHARSET=2;SHIFTJIS_CHARSET=
40、128 ;HANGEUL_CHARSET=129;GB2312_CHARSET=134;CHINESEBIG5_CHARSET = 136;OEM_CHARSET =255;JOHAB_CHARSET=130;HEBREW_CHARSET =177;ARABIC_CHARSET=178;GREEK_CHARSET=161 ;TURKISH_CHARSET =162;VIETNAMESE_CHARSET = 163 ; THAI_CHARSET =222 ;EASTEUROPE_CHARSET = 238; RUSSIAN_CHARSET =204;度,舉個(gè)例子:Orientation:旋轉(zhuǎn)角度
41、,單位是1/10/代碼:con stS ='萬一的Delphi 博客'begi nCanvas.Font.Style :=fsBold;Canvas.Font.Color :=clRed;Canvas.Font.Height :=32;Canvas.Font.Orientation :=450 ;Canvas.TextOut( 0, ClientHeight-20 , S);end;/效果圖:Delphi 的繪圖功能11- TPen類(上)/TPen的主要屬性有四:Color 、Width、Style 、ModeColor:顏色Width:寬度;默認(rèn)是1;如果賦予=0 的值,會(huì)
42、使用默認(rèn)值Style:樣式;Delphi定義了筆樣式枚舉TPenStyle,包含以下樣式:psSolid=0; 實(shí)線psDash=1; 段線;要求筆寬=1psDot=2; 點(diǎn)線;要求筆寬=1psDashDot =3; 線、點(diǎn);要求筆寬=1psDashDotDot =4; 線、點(diǎn)、點(diǎn);要求筆寬=1psClear=5; 不可見psln sideFrame =6; 實(shí)線;但筆寬是向里擴(kuò)展psUserStyle =7; 自定義,Delphi.Net支持psAlternate =8; 交替,Delphi.Net支持/下面的例子依次展示了各種樣式vari,x,y, n: In teger;begi nx
43、:=10;y :=15;n := Clie ntWidth -2*x;Canvas . Pen. Color := cIRed;for i :=0 to 8 dobegi nCanvas.Pen. Style := TPenStyle(i);Canvas.MoveTo(x, y);Canvas.LineTo(x + n, y);y := y +15;end;end;/效果圖:Mode:畫筆與背景的顏色混合模式;Delphi疋義了模式枚舉pmBlack總是黑色pmWhite總是白色pmNop畫筆無效pmNot背景色取反pmCopy畫筆設(shè)置的顏色pmNotCopy畫筆顏色取反pmMergePe n
44、Not畫筆顏色與背景顏色的反色的組合pmMaskPe nNot畫筆顏色與背景公共色的反色的組合pmMergeNotPen畫筆顏色取反后與背景顏色的組合pmMaskNotPe n畫筆的反色與背景的公共色的組合pmMerge畫筆顏色與背景顏色的組合pmNotMergepmMerge 的反色pmMask畫筆與背景公共顏色的組合pmNotMaskpmMask的反色pmXor畫筆顏色與背景顏色的Xor組合pmNotXorpmXor的反色TPe nM ode.包含以下模式:/顏色模式測(cè)試程序vari,x,y,w,n: Integer;begi n先畫豎的顏色背景x :=0;y :=0;w := Clie
45、ntWidthdiv 18;for i :=0 to 18 dobegi nCan vas. Brush . Color := Palette In dex(i);Canvas . FillRect(Rect(x, y, x+w, ClientHeight);x := x + w;end;再按不同模式依次畫16條紅色的橫線x :=0;y :=20;n := ClientWidth;Canvas . Pen. Width :=4;Canvas . Pen. Color := clRed;for i :=0 to 15 dobegi nCanvas.Pen. Mode := TPenMode(i)
46、;Canvas.MoveTo(x, y);Canvas.LineTo(x + n, y);y := y + end;20;end;/效果圖:Delphi的繪圖功能12- TPen類(下):學(xué)習(xí)橡皮線/奇妙的異或運(yùn)算,就這些簡(jiǎn)單的代碼,反復(fù)點(diǎn)擊按鈕procedure TForml . Butt on 1Click(Se nder: TObject);begi nCanvas.Pen. Color := clYellow;指疋筆顏色為黃色Canvas.Pen. Width :=20;筆寬 20Canvas.Pen. Mode := pmXor;指疋畫筆模式為:畫筆色與背景色的異或運(yùn)算畫線Canva
47、s.MoveTo( 0, 0);Canvas.LineTo(ClientWidth,ClientHeight);end;/效果圖:/做一個(gè)橡皮線的示例 un it Un it1;in terface usesWin dows, Messages, SysUtils, Varia nts. Classes, Graphics, Con trols, Forms,Dialogs, StdCtrls;typeTForm1 = class (TForm)procedureFormMouseDow n(Sen der: TObject; Butt on: TMouseButt on;Shift: TSh
48、iftState; X, Y: In teger);procedure FormMouseMove(Se nder: TObject; Shift: TShiftState; X, Y: In teger);procedureFormMouseUp(Se nder: TObject; Butt on: TMouseButt on;Shift: TShiftState; X, Y: In teger);end;varForml: TForml;impleme ntati on$R *dfmvarx1,y1,x2,y2: Integer;直線兩個(gè)端點(diǎn)的坐標(biāo)f: Boolean;判斷鼠標(biāo)是否點(diǎn)下pr
49、ocedure TForm1 . FormMouseDow n(Sen der: TObject; Butt on: TMouseButt on;Shift: TShiftState; X, Y: In teger);begi nx1 := X; y1 := Y;x2 := X; y2 := Y;Canvas . Pen. Color := clRed;Canvas . Pen. Width :=2;Canvas . Pen. Mode := pmXor;f := True;end;procedure TForm1 . FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: In teger);begi nif f thenbegi n擦除Canvas. MoveTo(x1, y1);Canvas. LineTo(x2, y2);x2 := X; y2 := y;重繪Canvas. MoveTo(x1, y1);Canvas. LineTo(x2, y2);end;end;procedure TForml . FormMouseUp(Se nder: TObject; Butt on: TMouseButt on;Shift: TShiftState; X, Y: In teger);begi nif
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《標(biāo)準(zhǔn)理解與實(shí)施》課件
- 《盾構(gòu)施工測(cè)量培訓(xùn)》課件
- 《員工安全教育講義》課件
- 《測(cè)序技術(shù)介紹》課件
- 單位管理制度集合大全職工管理篇
- 單位管理制度集粹選集員工管理篇十篇
- 單位管理制度匯編大全職工管理篇
- 單位管理制度合并匯編【職員管理篇】
- 《客服分析報(bào)告會(huì)》課件
- 單位管理制度分享合集【人力資源管理】十篇
- 廣東省深圳市2023-2024學(xué)年高一上學(xué)期期末考試物理試題(含答案)
- 自身免疫性腦炎護(hù)理常規(guī)
- 企業(yè)辦公區(qū)反恐防爆應(yīng)急預(yù)案
- 2025年慢性阻塞性肺疾病全球創(chuàng)議GOLD指南修訂解讀課件
- 實(shí)驗(yàn)室(化驗(yàn)室)管理規(guī)定
- GB/T 44481-2024建筑消防設(shè)施檢測(cè)技術(shù)規(guī)范
- 班主任月考成績(jī)質(zhì)量分析總結(jié)與反思
- 小學(xué)五年級(jí)家長(zhǎng)會(huì)-主題班會(huì)
- DB11T 211-2017 園林綠化用植物材料 木本苗
- 【3套試卷】人教版八年級(jí)數(shù)學(xué)上冊(cè)期末考試試題【答案】
- 單詞連連看答題闖關(guān)游戲課堂互動(dòng)課件1
評(píng)論
0/150
提交評(píng)論