|
pImage->Parent = Form1;
를 추가하시면 될것 같네요..
다음의 함수를 사용했었는데.. 저도 안되서 이것저것 추가했었기
때문에 쓸때없는것도 몇개 포함되었을것 같네요.. 되기는 확실히 됩니다.
void TForm1::AddImage(int index)
{
TImage *pImage = new TImage(this);
pImage->OnClick = ImageClick;
pImage->Parent = Form1;
pImage->AutoSize = true;
//path가 길면 error가 발생함.
pImage->Picture->LoadFromFile( GetCurrentDir() +"\\house.ico");
//random은 int를 return
//image가 파란 사각형 내부에만 나타나도록 함.
pImage->Left = random(Form1->Width - 100 -10 - pImage->Width) + 10;
pImage->Top = random(Form1->Height - 30 -10 - pImage->Height) + 10;
pImage->Visible = true;
ImageList->Add(pImage);
}
|