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

請問如何用BCB動態製造Image...

答題得分者是:RaynorPao
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-06 10:51:08 IP:203.204.xxx.xxx 未訂閱
各位板大,你們好... 我想在程式中..動態的產生Image於form上..... 是用bcb寫的... 謝謝大家的幫忙....
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-06 11:03:56 IP:203.73.xxx.xxx 未訂閱
引言: 各位板大,你們好... 我想在程式中..動態的產生Image於form上..... 是用bcb寫的... 謝謝大家的幫忙....
john0620 你好: 請參考以下的範例程式碼 < class="code"> TImage *img=new TImage(Application); img->Parent=this; img->Left=0; img->Top=0; img->Width=100; img->Height=100; img->Canvas->Brush->Color=clWhite; img->Canvas->FillRect(Rect(0, 0, img->Width, img->Height)); -- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
Genesis
一般會員


發表:1
回覆:5
積分:1
註冊:2003-07-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-06 11:06:21 IP:211.74.xxx.xxx 未訂閱
假設要有100張    建立
TImage **IMG;
int t=100;    IMG = new TImage(i);    for(int i=0; iParent = form1;
  其他對IMG(i)的一些設定..)
}    刪除    for(int j=0 ; j    發表人 - Genesis 於 2003/08/06  11:08:03    發表人 - Genesis 於 2003/08/06  11:10:03
        
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-08-06 11:20:55 IP:211.75.xxx.xxx 未訂閱
不好意思....    再請教一下...    如果我要於form1中的button_event的程式碼執行時...    將Image產生於form2中..應改要如何做....    謝謝RaynorPao 及Genesis你們的說明...
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-08-06 11:22:44 IP:61.230.xxx.xxx 未訂閱
你好:    我也提供一下我的方法吧
 TForm *newForm        = new TForm(Form1);    //動態產生一個newform放image
 TImage *Image         = new TImage(newForm); //動態產生一個image至於newform
 Image->Parent         = newForm;
 Image->ParentShowHint = True;
 newForm->Width        = img_w 10;
 newForm->Height       = img_h 30;
 Image->Width          = img_w;
 Image->Height         = img_h;
 newForm->FormStyle    = fsStayOnTop;
 newForm->Position     = poScreenCenter;
這樣image能單獨show出在一個newform上,FYR
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-08-06 11:55:43 IP:211.75.xxx.xxx 未訂閱
我已參考RaynorPno的程式產生Image... TImage *img=new TImage(Form2); img->Parent=Form2; img->ParentShowHint = True; img->Left=0; img->Top=0; img->Width= 20; img->Height= 1024; img->Canvas->Brush->Color=clWhite; img->Canvas->FillRect(Rect(0, 0, img->Width, img->Height)); 如果我是將上面這段程式放入...FormCreate... 我在form的Timer中想要讓這個image->left做位移... img->Left ; img->Invalidate(); 但於Run時發生錯誤... [C Error] Unit2.cpp(67): E2451 Undefined symbol 'img' 我應該如何解決.....謝謝!! 發表人 - john0620 於 2003/08/06 11:59:25
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-08-06 12:07:12 IP:203.73.xxx.xxx 未訂閱
引言: 我已參考RaynorPno的程式產生Image... TImage *img=new TImage(Form2); img->Parent=Form2; img->ParentShowHint = True; img->Left=0; img->Top=0; img->Width= 20; img->Height= 1024; img->Canvas->Brush->Color=clWhite; img->Canvas->FillRect(Rect(0, 0, img->Width, img->Height)); 如果我是將上面這段程式放入...FormCreate... 我在form的Timer中想要讓這個image->left做位移... img->Left ; img->Invalidate(); 但於Run時發生錯誤... [C Error] Unit2.cpp(67): E2451 Undefined symbol 'img' 我應該如何解決.....謝謝!!
john0620 你好:
(1)把 TImage *img; 設為全域變數或著是 class 中的一個 member
(2)有關位移的部分 (可用滑鼠或鍵盤控制),請參考以下類似的文章
   >    -- 
        
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
taishyang
站務副站長


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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-08-06 14:31:09 IP:140.135.xxx.xxx 未訂閱
Genesis您好:
 
TImage **IMG;
int t=100;
IMG = new TImage(i);
for(int i=0; iParent = form1;
  其他對IMG(i)的一些設定..)
}
您的程式似乎有問題? JerryKuo您好: 您的程式似乎也有問題??沒有效果 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-08-06 14:38:51 IP:203.204.xxx.xxx 未訂閱
對ㄚ....我也試了...程式並不能跑...會有問題....    請問有人知道如何產生...(用bcb)    產生動態image的陣列嗎....    謝謝大家的幫忙!!.....
taishyang
站務副站長


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

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-08-06 14:57:32 IP:140.135.xxx.xxx 未訂閱
john0620您好:
引言: 請問有人知道如何產生...(用bcb) 產生動態image的陣列嗎....
產生
 
 TImage* ima[10];
 for (int i=0;i<10;i  )
 {
  ima[i]= new TImage(this);
  ima[i]->Parent=Form1;
  ima[i]->Left=(25 50*i);
  ima[i]->Top=(50);
  ima[i]->Height=50;
  ima[i]->Width=50;
  ima[i]->Canvas->Brush->Color=TColor(50*i);
  ima[i]->Canvas->FillRect(Rect(0, 0, ima[i]->Width, ima[i]->Height));
 }
刪除
for (int i=0;i<10;i  )
 {
   delete ima[i];
 }
順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~ 發表人 -
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-08-06 15:05:18 IP:210.68.xxx.xxx 未訂閱
引言:
 TForm *newForm        = new TForm(Form1);    //動態產生一個newform放image
 TImage *Image         = new TImage(newForm); //動態產生一個image至於newform
 Image->Parent         = newForm;
 Image->ParentShowHint = True;
 newForm->Width        = img_w 10;
 newForm->Height       = img_h 30;
 Image->Width          = img_w;
 Image->Height         = img_h;
 newForm->FormStyle    = fsStayOnTop;
 newForm->Position     = poScreenCenter;
 newForm->Show();
抱歉唷.. 因為沒有>>> 就可以看到一個動態的
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-08-06 15:14:31 IP:211.75.xxx.xxx 未訂閱
taishyang..Jerrykno..你好...    謝謝你們所提供的程式及說明....
john0620
一般會員


發表:38
回覆:17
積分:11
註冊:2003-07-01

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-08-07 09:57:14 IP:211.75.xxx.xxx 未訂閱
taishyang 你好:    我參考你的程式 /////////////////////////////// TImage* ima[10];  for (int i=0;i<10;i ) { ima[i]= new TImage(this); ima[i]->Parent=Form1; ima[i]->Left=(25 50*i); ima[i]->Top=(50); ima[i]->Height=50; ima[i]->Width=50; ima[i]->Canvas->Brush->Color=TColor(50*i); ima[i]->Canvas->FillRect(Rect(0, 0, ima[i]->Width, ima[i]->Height)); } 刪除 for (int i=0;i<10;i ) { delete ima[i]; } //////////////////////////////////////////////// 已經可以產生10張動態TImage.. 如果想將 TImage* ima[10]; 中的10當變數... 我的寫法如: int i; i=10; TImage* ima[i]; 執行時程式會產生錯誤... 可不可以麻煩請你幫我說明一下..... 謝謝...
taishyang
站務副站長


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

發送簡訊給我
#14 引用回覆 回覆 發表時間:2003-08-07 17:40:59 IP:140.135.xxx.xxx 未訂閱
john0620您好: 改成
const int i;
i=10;
TImage* ima[i];
即可 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~
Genesis
一般會員


發表:1
回覆:5
積分:1
註冊:2003-07-10

發送簡訊給我
#15 引用回覆 回覆 發表時間:2003-08-08 06:28:52 IP:210.64.xxx.xxx 未訂閱
引言: Genesis您好:
 
TImage **IMG;
int t=100;
IMG = new TImage(i);
for( int i=0; iParent = form1;
  其他對IMG(i)的一些設定..)
}
您的程式似乎有問題? JerryKuo您好: 您的程式似乎也有問題??沒有效果 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~ < face="Verdana, Arial, Helvetica"> 嗯,有地方寫錯了
TImage **IMG;
int t=100;
IMG = new TImage[i];
for(int i=0; iParent = form1;
  其他對IMG(i)的一些設定..)
}
發表人 - Genesis 於 2003/08/08 06:31:36
系統時間:2024-05-05 4:50:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!