|
폼 object inspector에 보면
windowstate 가 있습니다. 해당값을 wsmaximized로 넣으면
자동으로 해당도에 맞춰 최대화가 될겁니다.
리사이징 님이 쓰신 글 :
: 제작한 프로그램을 다양한 모니터의 해상도를 맞추기 위한 소스를 구현하고자합니다.
:
: 어찌해야할지 도움좀 부탁드립니다. 감사합니다 꾸벅!
:
:
: 코드끈 님이 쓰신 글 :
: : 그 말이 맞는것 같네요.
: :
: : 당장 생각나는건 TWinControl로 캐스팅하기전에
: : Components[i]->ClassName 으로 직접 확인하는 방법입니다.
: : 그 폼에 사용하는 Component중 TWinControl을 상속받지 않은 Component가
: : 몇 개 안 된다면 문제 없을 듯 합니다.
: :
: : TWinControl의 상속 여부만 확인하는 방법만 있으면 쌈박하게 해결 될것 같은데 말이죠...
: :
: : 상속 여부 확인하는 방법이 궁금해서
: : 코드끈이 짧음에도 불구하고 한번 적어봤습니다.
: :
: :
: :
: :
: :
: : 리사이징 님이 쓰신 글 :
: : : 어떤 해상도이든간에 프로그램 최대화 했을때 화면이 다 알맞게 배치되게끔 하기위해
: : : 조대현 Clau. 님께서 달아주신 예제 소스를 보고 프로그램에 적용했더니 오류가 납니다.
: : : Access violation at address 오류가 납니다.
: : : 아마 예상키로 사이즈를 참조할 수 없는 Socket , OpenDialog 컴포넌트 등등이 오류나서 그런것 같습니다.
: : : 혹시 맞는지 확인좀 부탁드립니다. 감사합니다.
: : :
: : : //---------------------------------------------------------------------------
: : :
: : : #include <vcl.h>
: : : #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++;
: : : }
: : : }
: : : //---------------------------------------------------------------------------
|