|
유엔아이 입니다.
virtula function '_fastcall TCommatext::KeyPress(char &)' conflicts with base class 'TcustomMemo'
이메세지는 베이스 크래스인 TCustomMemo 에 KeyPress(char &) 라는 펑션이
virtual 함수로 존재 한다 이겁니다.
따라서 .. 자식 크래스에서도 함수를 버춸 함수로 작성 하여야 합니다.
: protected:
: void __fastcall KeyPress(char &Key);
이부분이
: protected:
: virtual void __fastcall KeyPress(char &Key);
로~~
그럼
모라 님이 쓰신 글 :
: 안녕하세요. 초보적인 질문에 매너있고 지속적인 답변. 고맙습니다. :)
:
: 그러고 이번에도 질문을 하고자 합니다. ^^;
:
: 볼랜드 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;
: }
: }
: //---------------------------------------------------------------------------
:
|