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
[23427] TCollection을 이용해 콤포넌트 만들던 중... 에러 원인을 도저히 모르겠어요..ㅜㅜ
답다비 [] 653 읽음    2002-12-28 04:33
※아래의 소스는 앞에서 제라툴님이 올려주신 간단한 TPoints소스를 기반으로한
  간단한 TCollection 사용테스트 한것입니다.

뒷페이지로 넘어가서 그런지 아무런 답변이 없어서요.. 다시 정리해서 올립니다.
죄송... 머가 문제인지 도무지 모르겠어요..

★ 에러는 TTestPanel이란 새 컴포넌트를 다 만든후 패키지로 묶어서 시빌더에 등록하고나서
★ 새프로젝트를 열어서 디자인타임에 이 TTestPanel을 폼위에 올려놓고나서..
★ 컴파일을 하려구해도 컴포넌트 삭제를 시키려해도..

★ "List Index out of bounds(-2147483648)" 이란 에러창만을 띄웁니다..

★ 아래에 소스를 같이 올리니 꼭 답변을 달아주세요..ㅡㅜ
★ 그냥 동적생성을 할때는 이런문제가 생기지 않았는데 왜이런지???
★ 부탁드립니다...ㅜ.ㅜ


(소스 간략설명)
  TCollectionItem에서 상속받은 TPointItem이란 클래스를 만들고
  TCollection을 상속받아 만든 TPoints라는 클래스를 만듭니다.

  그리고 TPanel콤포넌트를 상속받아서 새로 만들고
  __property TPoints* Items을 추가합니다.

<<소스>>

//=TPoints.h 파일(TPointItem,TPoints)==============================================

#ifndef TPointsH
#define TPointsH
#include <SysUtils.hpp>
#include <Classes.hpp>
//---------------------------------------------------------------------------
class TPointItem : public TCollectionItem
{
private:
    int Fx;
    int Fy;
    int FGroupIndex;
__published:
    __property int x  = { read=Fx, write=Fx };
    __property int y  = { read=Fy, write=Fy };
    __property int GroupIndex  = { read=FGroupIndex, write=FGroupIndex };
};
//------------------------------------------------------------------------
class TPoints : public TCollection
{
    typedef Classes::TCollection inherited;

private:
    HIDESBASE TPointItem* __fastcall GetItem(int Index);
    HIDESBASE void        __fastcall SetItem(int Index, TPointItem* Value);

protected:
public:
    __fastcall TPoints() : TCollection(__classid(TPointItem)){ };
    HIDESBASE TPointItem* __fastcall Add(void);
__published:
    __property TPointItem* Items[int Index] = {read=GetItem, write=SetItem};
};
#endif
//===================================================================================


//=TPoints.cpp 파일==================================================================

#pragma hdrstop
#include "TPoints.h"
#pragma package(smart_init)

TPointItem* __fastcall TPoints::GetItem(int Index)
{
    return (TPointItem*)(inherited::GetItem(Index));
}
void __fastcall TPoints::SetItem(int Index, TPointItem* Value)
{
    inherited::SetItem(Index, (TCollectionItem*)Value);
}
TPointItem* __fastcall TPoints::Add(void)
{
    return (TPointItem*)inherited::Add();
}
//===================================================================================


//=TTestPanel.h 파일=================================================================
#ifndef TestPanelH
#define TestPanelH

#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------

#include "TPoints.h"

class PACKAGE TTestPanel : public TPanel
{
private:
    TPoints* FItems;
protected:
public:
    __fastcall TTestPanel(TComponent* Owner);
__published:
    __property TPoints* Items={read=FItems,write=FItems};
};
#endif
//===================================================================================


//=TTestPanel.cpp 파일===============================================================

#include <vcl.h>
#pragma hdrstop

#include "TestPanel.h"
#pragma package(smart_init)

static inline void ValidCtrCheck(TTestPanel *)
{
    new TTestPanel(NULL);
}

__fastcall TTestPanel::TTestPanel(TComponent* Owner)
    : TPanel(Owner)
{
    FItems = new TPoints;
}

namespace Testpanel
{
    void __fastcall PACKAGE Register()
    {
         TComponentClass classes[1] = {__classid(TTestPanel)};
         RegisterComponents("Standard", classes, 0);
    }
}
//====================================================================================

이상 소스입니다.. 꼭 부탁드립니다. ㅜ.ㅜ

+ -

관련 글 리스트
23427 TCollection을 이용해 콤포넌트 만들던 중... 에러 원인을 도저히 모르겠어요..ㅜㅜ 답다비 653 2002/12/28
23455     Re:TCollection을 이용해 콤포넌트 만들던 중... 에러 원인을 도저히 모르겠어요..ㅜㅜ 제라툴 656 2002/12/30
23467         Re:Re:제라툴님 감솨~ 글구 참 위의 에러해결은 다른길로 해결했어요.. 함보세요.... 답다비 605 2002/12/31
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.