|
이렇게 하니 원하는데로 됩니다.
밤을꼬박샛네요..
라스코니님 이른아침에 정말감사합니다.
초보에게 크나큰 지원을주셔서감사합니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
TImage *I[10];
AnsiString a;
int X=0;
int i=0;
TButton* cls;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit1->Text = IntToStr(X);
I[X] = new TImage(this);
I[X]->Name = String("Imgcnd_") + X + String("_");
I[X]->Width = 189;
I[X]->Height = 91;
I[X]->Stretch = true;
I[X]->AutoSize = false;
I[X]->Visible = true;
I[X]->Parent = Form1;
I[X]->Picture->LoadFromFile("C:WEFEFW.bmp");
I[X]->Left = X;
I[X]->Top = 0;
I[X]->Transparent = true;
X++;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int i = 0;
//delete [] I;
for(int i = 0; i < 10; i++)
{
if( I[i] != NULL)
{
delete I[i];
}
else
{
break;
}
}
X = 0;
}
//---------------------------------------------------------------------------
ㅋㅊㅌㅍㅌㅋㅊㅍㅌㅍ 님이 쓰신 글 :
: 라스코니님
:
: 제가 I[0]을 동적생성하고 I[0] delete를하고 다시 I[0] 의 동적생성을원하는데 이거는 불가능한건가요?
:
:
:
: 라스코니 님이 쓰신 글 :
: : delete I[i];
: : 가 아니라
: :
: : delete [] I; 으로 하셔야 할 듯..
: :
: : 아니 그런데 I[100000] 이나 되는데 다 new로 assign 되지는 않을 것 같고,,,,
: :
: : for(int i = 0; i < 100000; i++)
: : {
: : if( I[i] != NULL)
: : delete I[i];
: : }
: :
: : 가 되어야 할 듯요.
: :
: : ㅋㅊㅌㅍㅌㅋㅊㅍㅌㅍ 님이 쓰신 글 :
: : : 이렇게해서 NULL값 넣어주는데도... 에러가뜨네요.. 방법좀알려주세요
: : :
: : :
: : : //---------------------------------------------------------------------------
: : :
: : : #include <vcl.h>
: : : #pragma hdrstop
: : :
: : : #include "Unit1.h"
: : : TImage *I[100000];
: : : AnsiString a;
: : : int X=0;
: : : int i=0;
: : : TButton* cls;
: : : //---------------------------------------------------------------------------
: : : #pragma package(smart_init)
: : : #pragma resource "*.dfm"
: : : TForm1 *Form1;
: : : //---------------------------------------------------------------------------
: : : __fastcall TForm1::TForm1(TComponent* Owner)
: : : : TForm(Owner)
: : : {
: : : }
: : : //---------------------------------------------------------------------------
: : :
: : : void __fastcall TForm1::Button1Click(TObject *Sender)
: : : {
: : : I[X] = new TImage(this);
: : : I[X]->Name = String("Imgcnd_") + X + String("_");
: : : I[X]->Width = 189;
: : : I[X]->Height = 91;
: : : I[X]->Stretch = true;
: : : I[X]->AutoSize = false;
: : : I[X]->Visible = true;
: : : I[X]->Parent = Form1;
: : : I[X]->Picture->LoadFromFile("C:EWRWER.bmp");
: : : I[X]->Left = X;
: : : I[X]->Top = 0;
: : : I[X]->Transparent = true;
: : :
: : : X++;
: : : }
: : : //---------------------------------------------------------------------------
: : :
: : :
: : : void __fastcall TForm1::Button3Click(TObject *Sender)
: : : {
: : : int i = 0;
: : :
: : : delete Form1;
: : : delete I[i];
: : :
: : : for(int i = 0; i < 5; i++)
: : : {
: : : I[i]=NULL;
: : : }
: : :
: : : X = 0;
: : :
: : : Application->CreateForm(__classid(TForm1), &Form1);
: : : Form1->Show();
: : : }
: : : //---------------------------------------------------------------------------
|