|
안녕하세요...
scrollbox에 panel을 client속성으로 놓고, 버튼등이 눌렸을때... 패널을 생성(MakePanel ) 해주는
함수를 호출했는데... 두번째 호출에는 패널안에 생성해 놓은 라벨같은것이 보이질 않습니다...(첨부 화일 참조 )
왜 그런 현상이 나타는 것인가요?
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i = 0 ;
int j = 0;
/* 첫번째 호출에는(i==0) 정상으로 라벨이 정상적으로 표시...
두번째 호출 (i==1 ) 에는 라벨에 표시안됩니다 ... 왜 이런 현상이? 나타나는지요?
for ( i = 0 ;i < 2 ; i ++ ) MakePanel( (i * 150 )+2 , (j * 300 ) + 2 , 150, 300 );
}
TPanel * __fastcall TForm1:: MakePanel(int left,int top , int width, int height)
{
static int cnt = 0;
int spaceFromTop = 5;
TPanel *p = new TPanel (this);
p->Parent = ScrollBox1;
p->Color=clRed;
p->Left = left;
p->Top = spaceFromTop+ top;
p->Width = width;
p->Height = height;
TLabel *l1 = new TLabel(this);
l1->Parent=p;
l1->Caption = "첫번째 라벨";
l1->Font->Style= TFontStyles() <<fsBold;
l1->Left= p->Left +2;
l1->Top = p->Top +2;
l1->Visible=true;
TImage *i= new TImage(this);
i->Parent=p;
i->Left = p->Left + 2;
i->Top = l1->Top +5;
i->Width = 131;
i->Height = 177;
i->AutoSize=false;
i->Stretch=true;
//i->Picture->Bitmap->LoadFromFile("c:\\test.bmp");
i->Visible=true;
TLabel *l2 = new TLabel(this);
l2->Parent=p;
l2->Caption = "두번째 라벨";
l2->Font->Style= TFontStyles() <<fsBold;
l2->Left= p->Left +2;
l2->Top = i->Top + i->Height + 5;
l2->Visible=true;
p->Visible=true;
return p;
}
수고하세요..
|