C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[53537] Re:Re:답변 감사합니다. 테스트해볼게요.(냉무)
나래피오 [woni3] 1254 읽음    2008-05-28 16:50
조대현.Clau 님이 쓰신 글 :
:
: : : : Untitled Document : : : : :

저두 예전에 필요해서 Resize에 구현했습니다.

:

아마 이정도면 컴포넌트로 구현가능 하겠네요.

:

1. Form Create에서 각 컨트롤의 위치, 사이즈를 구조체에 기록해서 Tag에 넣고, Form 사이즈도 전역변수에 넣어둡니다.
: 2. Form Resize에서 초기 사이즈와 변경된 사이즈의 비율을 계산해서 곱해줍니다.
: 3. Form Destroy에서 Tag에 연결된 구조체를 날려줍니다.
: 4. 컴포넌트의 Tag를 쓰셔야 한다면 TList나 구조체배열 쓰시면 됩니다.

:

예제 소스입니다.

:

 

:

 

:

//---------------------------------------------------------------------------

:

#include
: #pragma hdrstop

:

#include "Unit2.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: struct SDefaultContorl{
: int Width;
: int Height;
: int Left;
: int Top;
: };

:

int DefaultWidth;
: int DefaultHeight;

:

TForm2 *Form2;
: //---------------------------------------------------------------------------
: __fastcall TForm2::TForm2(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
: void __fastcall TForm2::FormCreate(TObject *Sender)
: {
: TWinControl *winCtrl;
: SDefaultContorl *defCtrl;
: int i;

:

i = 0;
: while(i < ComponentCount){
: winCtrl = (TWinControl *)Components[i];

:

defCtrl = new SDefaultContorl;
: defCtrl->Width = winCtrl->Width;
: defCtrl->Height = winCtrl->Height;
: defCtrl->Left = winCtrl->Left;
: defCtrl->Top = winCtrl->Top;

:

winCtrl->Tag = (int)defCtrl;
: i++;
: }
: DefaultWidth = Width;
: DefaultHeight = Height;

:

}
: //---------------------------------------------------------------------------
: void __fastcall TForm2::FormResize(TObject *Sender)
: {
: TWinControl *winCtrl;
: SDefaultContorl *defCtrl;
: int i;
: int iW, iH, iL, iT;
: float fZoomX, fZoomY;

:

i = 0;

:

fZoomX = float(Width) / float(DefaultWidth);
: fZoomY = float(Height) / float(DefaultHeight);
: while(i < ComponentCount){
: winCtrl = (TWinControl *)Components[i];
: defCtrl = (SDefaultContorl *)winCtrl->Tag;

:

iW = defCtrl->Width * fZoomX;
: iH = defCtrl->Height * fZoomY;
: iL = defCtrl->Left * fZoomX;
: iT = defCtrl->Top * fZoomY;

:

if(iW < 1) iW = 1;
: if(iH < 1) iH = 1;
: if(iL < 1) iL = 1;
: if(iT < 1) iT = 1;

:

winCtrl->Width = iW;
: winCtrl->Height = iH;
: winCtrl->Left = iL;
: winCtrl->Top = iT;
: i++;
: }

: }
: //---------------------------------------------------------------------------
: void __fastcall TForm2::FormDestroy(TObject *Sender)
: {
: TWinControl *winCtrl;
: SDefaultContorl *defCtrl;
: int i;

:

i = 0;
: while(i < ComponentCount){
: winCtrl = (TWinControl *)Components[i];
: defCtrl = (SDefaultContorl *)winCtrl->Tag;

:

delete defCtrl;
: winCtrl->Tag = NULL;
: i++;
: }

: }
: //---------------------------------------------------------------------------
:

: :

+ -

관련 글 리스트
53528 폼 리사이징.. 나래피오 1716 2008/05/28
53531     Re:폼 리사이징.. 조대현.Clau 1421 2008/05/28
53537         Re:Re:답변 감사합니다. 테스트해볼게요.(냉무) 나래피오 1254 2008/05/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.