全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1345
推到 Plurk!
推到 Facebook!

請教在屬性Brush->Style下可以更改背景顏色嗎?

尚未結案
jasper4877
一般會員


發表:17
回覆:4
積分:4
註冊:2004-08-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-08-13 18:11:14 IP:211.23.xxx.xxx 未訂閱
有一疑問,想請教各位前輩 1,可以改變在Canvas->Brush->Style=bsCross上的底色(因該是預設值為--黑色) 2,可以將網線的格點距離加大加寬嗎. 有參考資料可看.或是有別的方式可行呢.. 有上傳一劃面, 程式片斷,,,在一迴圈下執行 void TTMBForm::DrawPulses() {    TCanvas *canvas = PaintBox1->Canvas;    TRect rect = Panel3->ClientRect;    canvas->Brush->Color =clRed;//劃刷顏色(網線的顏色)    canvas->Brush->Style=bsCross;//垂直交又網狀    canvas->FillRect(rect);/將矩形佈滿顏色(有每Run一次清圖,再劃圖)    canvas->Font->Color = clRed;    canvas->Font->Size = 12;    canvas->TextOut(rect.Left + 10,b - canvas->TextHeight("A") - 3, title);    canvas->Pen->Color = clYellow;    canvas->Pen->Width = 6;    canvas->MoveTo(rect.Left, b);    canvas->LineTo(l1, b);    canvas->LineTo(l2, t);    canvas->LineTo(r1, t);    canvas->LineTo(r2, b);    canvas->LineTo(rect.Right, b); ///謝謝你能撥空看完,     發表人 - jasper4877 於 2004/08/13 18:16:18
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-13 20:43:59 IP:211.76.xxx.xxx 未訂閱
引言: 有一疑問,想請教各位前輩 1,可以改變在Canvas->Brush->Style=bsCross上的底色(因該是預設值為--黑色) 加入紅色部分程式碼。 2,可以將網線的格點距離加大加寬嗎. 可能是其內定的,可以試著用自己畫的Bitmap指定給Brush->Bitmap,但Brush->Color, Brush->Style就不能再指定以免蓋過Bitmap。 有參考資料可看.或是有別的方式可行呢.. 有上傳一劃面, 程式片斷,,,在一迴圈下執行 void TTMBForm::DrawPulses() { TCanvas *canvas = PaintBox1->Canvas; TRect rect = Panel3->ClientRect; canvas->Brush->Color = clWhite; // the color you want. canvas->Rectangle(rect); canvas->Brush->Color =clRed;//劃刷顏色(網線的顏色) canvas->Brush->Style=bsCross;//垂直交又網狀 canvas->FillRect(rect);/將矩形佈滿顏色(有每Run一次清圖,再劃圖) canvas->Font->Color = clRed; canvas->Font->Size = 12; canvas->TextOut(rect.Left 10,b - canvas->TextHeight("A") - 3, title); canvas->Pen->Color = clYellow; canvas->Pen->Width = 6; canvas->MoveTo(rect.Left, b); canvas->LineTo(l1, b); canvas->LineTo(l2, t); canvas->LineTo(r1, t); canvas->LineTo(r2, b); canvas->LineTo(rect.Right, b); ///謝謝你能撥空看完,
因覺得這個問題還滿有意義的,所以寫了個可以完成指定網格大小與顏色的程式,供您參考。< class="code"> //--------------------------------------------------------------------------- void setGridLine(TImage *image, TColor bgColor, int w, int h, TColor penColor, int pw=1) { TCanvas *canvas= image->Picture->Bitmap->Canvas; canvas->Pen->Color = penColor; canvas->Brush->Color = bgColor; image->Picture->Bitmap->Width = w; image->Picture->Bitmap->Height = h; image->Picture->Bitmap->Canvas->FillRect( Rect(0,0,image->Picture->Width, image->Picture->Height) ); canvas->Pen->Width = pw; canvas->MoveTo(pw-(pw 1)/2, 0); canvas->LineTo(pw-(pw 1)/2, h); canvas->MoveTo(0, pw-(pw 1)/2); canvas->LineTo(w, pw-(pw 1)/2); } void __fastcall TForm1::Button1Click(TObject *Sender) { int pw=4, w=40, h=30; TColor bgColor=clWhite, penColor = clRed; setGridLine(Image1, bgColor, w, h, penColor, pw); Form1->Canvas->Brush->Bitmap = Image1->Picture->Bitmap; Form1->Canvas->FillRect(Form1->ClientRect); } //--------------------------------------------------------------------------- RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====##### 發表人 - richtop 於 2004/08/13 20:45:43 發表人 - richtop 於 2004/08/13 21:54:56
系統時間:2024-05-14 8:44:19
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!