畫在Brush上的psDashDotDot線會有顏色,可以避免嗎? |
尚未結案
|
David
一般會員 發表:13 回覆:26 積分:7 註冊:2002-04-14 發送簡訊給我 |
請問前輩們,我在一個有顏色的Brush區域上,繪製一條線,線的型態為psDashDotDot,線的Dash與Dash間會有顏色,可以避免嗎?因為在Brush區域外的就沒顏色,請大家幫幫忙... 以下是我的程式內容
主要是一個form上放一個Button1和PaintBox1元件,選取Button1去繪製圖形到PaintBox1上...程式中也有我的一些需求說明,用//註明。 ======================== unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls; type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
aBitmap1: TBitmap;
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject);
var
aCanvas1: TCanvas;
begin
aBitmap1 := TBitmap.Create;
//設定
aBitmap1.Width := PaintBox1.Width;
aBitmap1.Height := PaintBox1.Height;
aBitmap1.TransparentColor := clNone;
aBitmap1.Transparent := True;
aBitmap1.TransparentMode := tmAuto; aCanvas1 := aBitmap1.Canvas; aCanvas1.Brush.Color := clBlack;
aCanvas1.Polygon([Point(10, 10), Point(330, 10), Point(330, 350), Point(10, 350)]); aCanvas1.Pen.Color := clRed;
aCanvas1.Brush.Color := clNone;//Dash與Dash間出現aCanvas1.Brush.Color 設定的顏色,但若設定為clNone還是會出現白色...
aCanvas1.Pen.Style := psDashDotDot; aCanvas1.PolyLine([Point(30, 0), Point(30, 390), Point(300, 0), Point(300, 390)]); PaintBox1Paint(Sender);//這一行如果不寫時,剛執行Button1後的成果就是我要的,但是如果視窗被遮蓋後再重新Active後,它的重劃又會使Dash與Dash間出現aCanvas1.Brush.Color 設定的顏色,及使用clNone也會有白色
end; procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Draw(0, 0, aBitmap1);
end; end. ========================== 發表人 - David 於 2004/02/20 08:10:09
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |