Component Writer's Guide Supplement


PAGE 4-10

Remove:
typedef TFloatProperty ThisClass;

PAGE 4-13

The snippet that called RegisterPropertyEditor incorrectly passes type names as parameters. When specifying types as parameters in calls to RegisterPropertyEditor use __classid(TypeName). So your own call should like: RegisterPropertyEditor(__typeinfo(TMenuItem),__classid(TMenu), "",__classid(TMenuItemProperty));

PAGE 8-4

When defining and declaring Message handlers for user messages and Windows messages use a TMessage reference for the single parameter rather than a TMessage pointer.
Change:
void __fastcall WMPaint(TWMPaint* Message)
To:
void __fastcall WMPaint(TWMPaint& Message)

PAGE 8-7

Change:
void __fastcall CMChangeColor(TMessage* Message);
To:
void __fastcall CMChangeColor(TMessage& Message);
Change:
void __fastcall TMyControl::CMChangeColor(TMessage* Message);
To:
void __fastcall TMyControl::CMChangeColor(TMessage& Message);

PAGE 12-4

Change:
void __fastcall WMSize(TWMSize* Message);
To:
void __fastcall WMSize(TWMSize& Message);
Change:
void __fastcall TSampleCalendar::WMSize(TMessage* Message);
To:
void __fastcall TSampleCalendar::WMSize(TMessage& Message);
Change:
DefaultColWidth = (Message->Width - GridLines)/7; DefaultRowHeight = (Message->Height - GridLines)/7;
To:
DefaultColWidth = (Message.Width - GridLines)/7; DefaultRowHeight = (Message.Height - GridLines)/7;

PAGE 14-2

In the public: section of TAboutBoxDlg, the constructor is missing, it should read: class TAboutDlgBox : public TComponent { private: protected: public: virtual __fastcall TAboutDlgBox(TComponent* Owner); __published: };

PAGE 14-3

In the public: section of TAboutBoxDlg, the constructor is missing, it should read: //--------------------------------------------------------------- #include #pragma hdrstop #include "aboutdlg.h" //--------------------------------------------------------------- __fastcall TAboutDlgBox::TAboutDlgBox(TComponent* Owner) : TComponent(Owner) { } //--------------------------------------------------------------- //--------------------------------------------------------------- namespace Aboutdlg { void __fastcall Register() { TComponentClass classes[1] ={__classid(TAboutDlgBox)}; RegisterComponents("Samples", classes,0); } } //---------------------------------------------------------------

PAGE 14-6

The final return from TAboutBoxDlg::Execute() uses return Result==IDOK, it should read: bool __fastcall TAboutDlgBox::Execute() { AboutBox=new TAboutBox(Application); bool Result; try { if (ProductName=="";) ProductName=Application->Title; AboutBox->ProductName->Caption=ProductName; AboutBox->Version->Caption=Version; AboutBox->Copyright->Caption=Copyright; AboutBox->Comments->Caption=Comments; AboutBox->Caption="About "+ProductName; Result=(AboutBox->ShowModal() == IDOK); } catch(...) { Result=false; } AboutBox->Free(); return Result; }