線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1287
推到 Plurk!
推到 Facebook!

在BCB想要畫Polynomial Line

尚未結案
shenglin
一般會員


發表:12
回覆:6
積分:3
註冊:2004-05-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-28 00:38:32 IP:61.64.xxx.xxx 未訂閱
大家好: 我想使用BCB的Polyline畫Polynomial的Line,我在VCL元件列中的System標籤下拉了一個PaintBox後用BCB Help的範例(如下)加到程式碼後Compiler都產生錯誤訊息.煩請指教. void __fastcall TForm1::PaintBox1Paint(TObject *Sender) { TPaintBox *pPB = (TPaintBox *)Sender; POINT points[6]; pPB->Canvas->Pen->Color = clWhite; points[0].x = 40; points[0].y = 10; points[1].x = 20; points[1].y = 60; points[2].x = 70; points[2].y = 30; points[3].x = 10; points[3].y = 30; points[4].x = 60; points[4].y = 60; points[5].x = 40; points[5].y = 10; pPB->Canvas->Polyline(points,5); } 謝謝指教 發表人 - shenglin 於 2004/07/28 00:46:23
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-28 01:07:28 IP:140.135.xxx.xxx 未訂閱
您好:  
POINT points[6];
改成
TPoint points[6];
即可 順心
richtop
資深會員


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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-28 01:11:50 IP:211.76.xxx.xxx 未訂閱
shenglin 您好:    因為BCB會作型態檢查,所以當型態不同於該函式原始定義時,會出現編譯錯誤。 將points轉成型態(const TPoint*)即可,參考下述程式碼。 < class="code">void __fastcall TForm1::PaintBox1Paint(TObject *Sender) { TPaintBox *pPB = (TPaintBox *)Sender; POINT points[6]; pPB->Canvas->Pen->Color = clRed; // 看起來比較清楚! points[0].x = 40; points[0].y = 10; points[1].x = 20; points[1].y = 60; points[2].x = 70; points[2].y = 30; points[3].x = 10; points[3].y = 30; points[4].x = 60; points[4].y = 60; points[5].x = 40; points[5].y = 10; pPB->Canvas->Polyline((const TPoint*)points,5); } RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
shenglin
一般會員


發表:12
回覆:6
積分:3
註冊:2004-05-02

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-28 01:38:36 IP:61.64.xxx.xxx 未訂閱
謝謝指教,不好意思,我利用這篇再問幾個基本問題 我把程式碼加進去後(不知位置對嗎) __fastcall TForm1::TForm1(TComponent* Owner)         : TForm(Owner) { } //---------------------------------------------------------------------------    void __fastcall TForm1::PaintBox1Paint(TObject *Sender) {      TPaintBox *pPB = (TPaintBox *)Sender;   POINT points[6];   pPB->Canvas->Pen->Color = clRed; // 看起來比較清楚!   points[0].x = 40;   points[0].y = 10;   points[1].x = 20;   points[1].y = 60;   points[2].x = 70;   points[2].y = 30;   points[3].x = 10;   points[3].y = 30;   points[4].x = 60;   points[4].y = 60;   points[5].x = 40;   points[5].y = 10;   pPB->Canvas->Polyline((const TPoint*)points,5);    }    會產生以下錯誤訊息 [C Error] Unit1.cpp(19): E2316 '_fastcall TForm1::PaintBox1Paint(TObject *)' is not a member of 'TForm1' 於是我在標頭檔加入 public: // User declarations __fastcall TForm1(TComponent* Owner); void __fastcall TForm1::PaintBox1Paint(TObject *Sender); }; 可以Compiler可是卻沒有畫出任何線,錯誤的地方在哪 謝謝各位的指教喔
richtop
資深會員


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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-07-28 02:03:25 IP:211.76.xxx.xxx 未訂閱
shenglin 您好: 不好意思,沒有說的很清楚。 因為BCB會自動產生程式碼,所以如果只是將程式片段copy進去,.h檔並不會產生相對的碼。 所以您只要先點選PaintBox,再選object inspector的event,找到OnPaint事件,double click,系統便會自動產生相關的程式碼,再把內容Copy進去應該就可以了。 RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
系統時間:2024-05-20 23:02:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!