C++builder a custom control
Http://docwiki.embarcadero.com/CodeExamples/XE8/en/RegisterComponents_%28C%2B%2B%29
void__fastcall Setfocuscontrol (twincontrol*Value); void__fastcall Cmdialogchar (twmkey&Message); void__fastcall cmtextchanged (tmessage&Message); protected: Virtual void__fastcall Notification (tcomponent*acomponent, toperation operation); Virtual void__fastcall Paint (void); Public: __fastcallVirtualTdemolabel (tcomponent*Aowner); __published: __property Caption; __property Color; __property Twincontrol* Focuscontrol = {Read=ffocuscontrol, write=Setfocuscontrol, NoDefault}; __property Font; __property Parentcolor; __property Parentfont; Public: __fastcallVirtual~tdemolabel (void) {} Begin_message_map Message_handler (Cm_dialogchar, Twmkey, Cmdialogchar); Message_handler (cm_textchanged, Tmessage, cmtextchanged); End_message_map (Tgraphiccontrol);};void__fastcall Package Register () {Tcomponentclass classes[1] ={__classid (Tdemolabel)}; Registercomponents ("Samples", classes,0); Registercomponents ("Mysystem", classes,0);} __fastcall Tdemolabel::tdemolabel (tcomponent*Aowner): Tgraphiccontrol (aowner) {Fcomponentstyle>>csinheritable; Width= -; Height= -;} void__fastcall tdemolabel::notification (Tcomponent *acomponent, toperation operation) {tgraphiccontrol::notification (acomponent, operation); if(Operation = = Opremove) && (acomponent = =Ffocuscontrol)) Ffocuscontrol=0;} void__fastcall Tdemolabel::setfocuscontrol (Twincontrol *Value) {Ffocuscontrol=Value; //calling Freenotification ensures that this component//Would receive an opremove if Value is either removed//From its owner or destroyed.Value-freenotification (Value);} void__fastcall Tdemolabel::P aint () {trect Rect=Clientrect; Canvas->font =Font; Canvas->brush->color =Color; Canvas-FillRect (Rect); DrawText (Canvas-Handle, Caption.t_str (), Caption.length (),&Rect, Dt_expandtabs| Dt_wordbreak |dt_left);} void__fastcall Tdemolabel::cmdialogchar (Tcmdialogkey &Message) { if(Ffocuscontrol! = NULL &&Enabled==true&&Isaccel (Message.charcode, Caption))if(ffocuscontrol->CanFocus ()) {Ffocuscontrol-SetFocus (); Message.result=1; }} void__fastcall tdemolabel::cmtextchanged (Tmessage &Message) {Invalidate ();}
C++builder a custom control