|
조대현 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++;
}
}
//---------------------------------------------------------------------------
|