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
[10686] 콤포넌트에서 다음과 같은 에러가 생겨요...
모라 [] 982 읽음    2001-09-06 06:06
안녕하세요. 초보적인 질문에 매너있고 지속적인 답변. 고맙습니다. :)

그러고 이번에도 질문을 하고자 합니다.  ^^;

볼랜드 c++빌더 정복 4.0에 있는 콤포넌트 만들기를 공부중인데요,

드디어 소스를 완성하고 콤파일 하니,

virtula function '_fastcall TCommatext::KeyPress(char &)' conflicts with base class 'TcustomMemo'

라는 에러가 뜨더군요. 저번처럼 명령어를 잘못 입력했나 싶어서 예제시디에 있는 화일들을

직접 돌려도 마찬가지네요.

돌린것은 빌더 5.0으로 돌렸는데  상관이 있을까요?

좋은 답변 바랍니다.


헤더부분(CommaText.h)


//---------------------------------------------------------------------------
#ifndef CommaTextH
#define CommaTextH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <StdCtrls.hpp>
//---------------------------------------------------------------------------
class PACKAGE TCommaText : public TCustomMemo
{
private:
    double FieldValue;
    void __fastcall SetFieldValue(double A);
    void __fastcall FormatNum();
    MESSAGE void __fastcall CMEnter(TCMEnter &Message);
    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER(CM_ENTER, TCMEnter, CMEnter)
    END_MESSAGE_MAP(TCustomMemo)
protected:
    void __fastcall KeyPress(char &Key);
public:
    __fastcall TCommaText(TComponent* Owner);
__published:
    __property Alignment ;
    __property BorderStyle ;
    __property Color ;
    __property Ctl3D ;
    __property DragCursor ;
    __property DragMode ;
    __property Enabled ;
    __property Font ;
    __property HideSelection ;
    __property MaxLength ;
    __property ParentColor ;
    __property ParentCtl3D ;
    __property ParentFont ;
    __property ParentShowHint ;
    __property PopupMenu ;
    __property ReadOnly ;
    __property ScrollBars ;
    __property ShowHint ;
    __property TabOrder ;
    __property TabStop ;
    __property Visible ;
    __property OnChange ;
    __property OnClick ;
    __property OnDblClick ;
    __property OnDragDrop ;
    __property OnDragOver ;
    __property OnEndDrag ;
    __property OnEnter ;
    __property OnExit ;
    __property OnKeyDown ;
    __property OnKeyPress ;
    __property OnKeyUp ;
    __property OnMouseDown ;
    __property OnMouseMove ;
    __property OnMouseUp ;
    __property OnStartDrag ;
    __property Text ;
       __property double Value = {read=FieldValue, write=SetFieldValue, default=1};
};
//---------------------------------------------------------------------------
#endif


cpp 화일 (CommaText.cpp)

//---------------------------------------------------------------------------
#include <vcl.h>
#include <ctype.h>
#pragma hdrstop

#include "CommaText.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TCommaText *)
{
    new TCommaText(NULL);
}
//---------------------------------------------------------------------------
__fastcall TCommaText::TCommaText(TComponent* Owner)
    : TCustomMemo(Owner)
{
    Alignment = taRightJustify;
    Width = 240;
    Height = 24;
    Parent = (TWinControl *) Owner;
    FieldValue = 0;
    FormatNum();
}
//---------------------------------------------------------------------------
namespace Commatext
{
    void __fastcall PACKAGE Register()
    {
        TComponentClass classes[1] = {__classid(TCommaText)};
        RegisterComponents("Samples", classes, 0);
    }
}
//---------------------------------------------------------------------------
void __fastcall TCommaText::SetFieldValue(double A)
{
    FieldValue = A;
    FormatNum();
}
//---------------------------------------------------------------------------
void __fastcall TCommaText::FormatNum()
{
    Text = FormatFloat("#,##0.#",FieldValue);
    return;
}
//---------------------------------------------------------------------------
void __fastcall TCommaText::CMEnter(TCMEnter &Message)
{
    SelectAll();
    return;
}
//---------------------------------------------------------------------------
void __fastcall TCommaText::KeyPress(char &Key)
{
  AnsiString TempStr = "";

  if (isalpha(Key) != 0) {
        Key = 0x00;
        return;
  }

  if (isdigit(Key) != 0) {

      if (SelLength > 0) ClearSelection();

      for (int i = 1; i < Text.Length() + 1; i++) {
            if (Text[i] == ',') continue;
            else TempStr += Text[i];
      }
      if (TempStr == "0") TempStr = "";
      TempStr += Key;
      FieldValue = StrToFloat(TempStr);

      FormatNum();
      Key = 0x00;
      SelStart = Text.Length();
      return;
  }
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
10686 콤포넌트에서 다음과 같은 에러가 생겨요... 모라 982 2001/09/06
10695     Re:콤포넌트에서 다음과 같은 에러가 생겨요... 최보현.U&I 1198 2001/09/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.