|
폼의 크기가 변경될 경우 폼안의 컴포넌트 크기를 폼의 크기에 맞추어 일정한 비율로 재조절하는 예라고 하는데
의도한 결과가 나오지 않습니다.
증가에 비해 감소가 빠른 속도로 일어나더군요..
코드 보시고 설명해주셨으면 합니다.
Contols[i]가 의미하는 것도 알고 싶구요
그럼 부탁드립니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int OldHeight, OldWidth;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
int i;
float px,py,t;
for(i=0;i<ControlCount;i++)
{
px=(float)Width/(float)OldWidth;
py=(float)Height/(float)OldHeight;
t=(Controls[i]->Top);
Controls[i]->Top=int(t*py);
t=Controls[i]->Left;
Controls[i]->Left=int(t*px);
t=Controls[i]->Height;
Controls[i]->Height=int(t*py);
t=Controls[i]->Width;
Controls[i]->Width=int(t*px);
}
OldHeight=Height;
OldWidth=Width;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
OldHeight=Height;
OldWidth=Width;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
|