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
[43075] TSpeedButton과 TImage 합친 컴포넌트 만들기...
B [cyberpd] 978 읽음    2005-12-26 15:08
TImage와 TSpeedButton이 같은 크기, 같은 위치에 놓이도록 컴포넌트로 만들려고 합니다.

TSpeedButton을 상속받은 새로운 클래스안에서 TImage를 멤버로 하는 컴포넌트를 만들었는데,
Object Inspector 에서 수치를 입력하면 같이 변경은 됩니다만,
폼 디자인에서 새로만든 버튼을을 움직여도  TImage 컨트롤이 화면상에서 같이 안움직이네요.

폼 디자인에서 같이 움직이게 하려면 어떻게 해야하죠??


///////////////////////////////////////////////////////////////////////////////
// .h
class PACKAGE TMyImageButton : public TSpeedButton
{
private:
    TImage* FImage;

    void __fastcall SetLeft(int left);
    void __fastcall SetTop(int left);
    void __fastcall SetWidth(int width);
    void __fastcall SetHeight(int height);
   
protected:
public:
    __fastcall TMyImageButton(TComponent* Owner);
__published:
    __property TImage* Image={ read=FImage };
    __property int Left={ read=FLeft, write=SetLeft };
    __property int Top={ read=FTop, write=SetTop};
    __property int Width={ read=FWidth, write=SetWidth };
    __property int Height={ read=FWidth, write=SetWidth };
};
//---------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////
// .cpp
__fastcall TMyImageButton::TMyImageButton(TComponent* Owner)
    : TSpeedButton(Owner)
{
    FImage=new TImage(Owner);
    FImage->Parent=dynamic_cast<TWinControl*>(Owner);
    FImage->Left=TSpeedButton::Left;
    FImage->Top=TSpeedButton::Top;
    FImage->Width=TSpeedButton::Width;
    FImage->Height=TSpeedButton::Height;
}
//---------------------------------------------------------------------------

void __fastcall TMyImageButton::SetLeft(int left)
{
    TSpeedButton::Left=left;
    FImage->Left=left;
}
//---------------------------------------------------------------------------

void __fastcall TMyImageButton::SetTop(int top)
{
    TSpeedButton::Top=top;
    FImage->Top=top;
}
//---------------------------------------------------------------------------

void __fastcall TMyImageButton::SetWidth(int width)
{
    TSpeedButton::Width=width;
    FImage->Width=width;
}
//---------------------------------------------------------------------------

void __fastcall TMyImageButton::SetHeight(int height)
{
    TSpeedButton::Height=height;
    FImage->Height=height;
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
43075 TSpeedButton과 TImage 합친 컴포넌트 만들기... B 978 2005/12/26
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.