在BCB想要畫Polynomial Line |
尚未結案
|
shenglin
一般會員 發表:12 回覆:6 積分:3 註冊:2004-05-02 發送簡訊給我 |
大家好:
我想使用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 發送簡訊給我 |
|
richtop
資深會員 發表:122 回覆:646 積分:468 註冊:2003-06-10 發送簡訊給我 |
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 發送簡訊給我 |
謝謝指教,不好意思,我利用這篇再問幾個基本問題
我把程式碼加進去後(不知位置對嗎)
__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 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |