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

如何寫一個功能為新增表單並產生統計圖的函數

尚未結案
phorn
一般會員


發表:28
回覆:60
積分:17
註冊:2004-03-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-26 20:21:20 IP:203.70.xxx.xxx 未訂閱
我在本站找尋了動態新增表單的方法,那我把它寫在函數裡結果發生了一些問題 ,分別是Show出來的表單卻沒關閉與放大的按鈕,而我一並放在表單裡的元件卻顯示不出來,不知道是什麼原因,請有經驗的大大指導我一下好嗎??謝謝!!    這是我的函數程式碼:    void __fastcall TImageTool::Histogram(Graphics::TBitmap *ImageBitmap) {   if(ImageBitmap->Empty==true)return;   //影像暫存器若空的則跳出函數   Graphics::TBitmap *TempBitmap=new Graphics::TBitmap;   TempBitmap->Assign(ImageBitmap);TempBitmap->PixelFormat=pf24bit;   int N=TempBitmap->Width*TempBitmap->Height;   unsigned int Ni[256];   for(int i=0;i<256;i )Ni[i]=0; for(int y=0;yHeight;y ) { Byte*ptr=(Byte*)TempBitmap->ScanLine[y]; for(int x=0;xWidth;x ) { int Gray=ptr[x*3 0]*0.114 ptr[x*3 1]*0.587 ptr[x*3 2]*0.299; Ni[Gray] ; } } for(int i=0;i<256;i ) delete TempBitmap; TForm *ChartForm=new TForm(this); TChart *GaryChart=new TChart(ChartForm); TChartSeries *Series=new TChartSeries(GaryChart); ChartForm->FormStyle =fsStayOnTop; ChartForm->BorderStyle =bsSingle; ChartForm->Caption ="Histogran"; ChartForm->Position =poScreenCenter; ChartForm->DoubleBuffered=true; ChartForm->Show(); GaryChart->RemoveAllSeries(); // 清除Chart1上所有舊 Series GaryChart->View3D=false; // 不要 3D 立體 GaryChart->Legend->Visible=false; // 不秀圖例說明 // 設定此 char Title 名稱 // 是 StringList 不是 String 所以不能用 Chart1->Title->Text="xxx" ...) GaryChart->Title->Text->Clear(); GaryChart->Title->Text->Add("test"); GaryChart->LeftAxis->Title->Caption="點數"; GaryChart->BottomAxis->Title->Caption="灰階值"; //宣告一個 THorizBarSeries 型態的 Series //其它的 Series 型態有哪些 請看 TChartSeries 之 Help Series=new THorizBarSeries(GaryChart) ; Series->ParentChart=GaryChart; Series->Marks->Visible=true; // 設定要提示說明 Series->Marks->Style=smsValue; // 提示說明內容為 Label //(註) Series1->Marks->Style 內容請參考 TSeriesMarksStyle 之 Help Series->SeriesColor=clBlue; // 設線條1為藍色,不設則自動給色 for(int i=0;i<=255;i )Series->Add(Ni[i],i,clRed); } 發表人 - taishyang 於 2004/07/26 20:40:37
李國維
高階會員


發表:42
回覆:287
積分:235
註冊:2003-02-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-26 21:10:43 IP:218.167.xxx.xxx 未訂閱
1.表單沒有關閉與放大的按鈕 試試看把BoarderStyle屬性設為bsSizeable. 2.表單裡的元件卻顯示不出來 試試看元件的parent屬性指向Form.
phorn
一般會員


發表:28
回覆:60
積分:17
註冊:2004-03-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-27 09:44:26 IP:210.244.xxx.xxx 未訂閱
引言: 1.表單沒有關閉與放大的按鈕 試試看把BoarderStyle屬性設為bsSizeable. 2.表單裡的元件卻顯示不出來 試試看元件的parent屬性指向Form.
謝謝國維大大的教導 二個問題解決了,可是第一個問題我是將 TForm *ChartForm=new TForm(this); TForm *ChartForm=new TForm(Form1); 才好的 會不會是因為我使用兩個. > 發表人 -
李國維
高階會員


發表:42
回覆:287
積分:235
註冊:2003-02-07

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-27 11:17:39 IP:218.167.xxx.xxx 未訂閱
function不一定要再寫一各cpp.舉例來說. 寫一各最小值的function.
//unit1.h
class TForm1 : public TForm
{
__published:        // IDE-managed Components
        void __fastcall FormCreate(TObject *Sender);
private:        // User declarations
        int __fastcall GetMinValue(int a,int b);
public:                // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//unit1.cpp
int __fastcall TForm1::GetMinValue(int a,int b)
{
 //Write code
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int i = GetMinValue(10,5);//使用此function
}
int 表示傳回int,如無傳回直可用void
phorn
一般會員


發表:28
回覆:60
積分:17
註冊:2004-03-03

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-07-27 16:01:00 IP:203.70.xxx.xxx 未訂閱
引言: function不一定要再寫一各cpp.舉例來說. 寫一各最小值的function.
//unit1.h
class TForm1 : public TForm
{
__published:        // IDE-managed Components
        void __fastcall FormCreate(TObject *Sender);
private:        // User declarations
        int __fastcall GetMinValue(int a,int b);
public:                // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//unit1.cpp
int __fastcall TForm1::GetMinValue(int a,int b)
{
 //Write code
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int i = GetMinValue(10,5);//使用此function
}
int 表示傳回int,如無傳回直可用void
謝謝國為大大你說的方法我已經知道了 我是因為函數太多所以才分兩個.
phorn
一般會員


發表:28
回覆:60
積分:17
註冊:2004-03-03

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-07-29 21:56:32 IP:203.70.xxx.xxx 未訂閱
雖然還有些問題尚未解決 不過還是謝謝國維大大的指導..... < >< >
系統時間:2024-04-29 8:09:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!