delphi - Firemonkey custom component -


i'm trying create cross-platform component firemonkey on delphi xe8...

but i'm facing problems. although properties "width" , "height" in object inspector compile apparently size settings ignored. , when reopen project component small. (i noticed width , height settings not saved dfm file).

note: other native components of firemonkey work properly, custom not.

whats problem?

unit fmx.card;  interface  uses   system.sysutils, system.classes, fmx.types, fmx.controls, fmx.graphics, system.types;  type  tcardnum = (ace, deuce, three, four, five, six, seven, eight, nine, ten, jack, queen, king);  tcardsuit = (clubs, diamonds, hearts, spades);  tcard = class(tcontrol) private   { private declarations }   fcardback: tbitmap;   fcarddown: boolean;   fcardset: tbitmap;   fcardnum: tcardnum;   fcardsuit: tcardsuit;   procedure setcarddown(avalue: boolean);   procedure setcardnum(avalue: tcardnum);   procedure setcardsuit(avalue: tcardsuit); protected   { protected declarations }   procedure paint; override; public   { public declarations }   constructor create(aowner: tcomponent); override; destructor destroy; override; published   { published declarations }   property position;   property rotationangle;   property width;   property height;   property carddown: boolean read fcarddown write fcarddown;   property cardnum: tcardnum read fcardnum write fcardnum;   property cardsuit: tcardsuit read fcardsuit write fcardsuit; end;  implementation  {$r 'cardresource.res'}  const   default_card_width  = 71;   default_card_height = 96;  { tcard }  constructor tcard.create(aowner: tcomponent); var   lrstream: tresourcestream; begin   inherited;   lrstream := tresourcestream.create(hinstance, 'cardback', rt_rcdata);   try     fcardback := tbitmap.createfromstream(lrstream);       lrstream.free;   end;   lrstream := tresourcestream.create(hinstance, 'cardset', rt_rcdata);   try     fcardset := tbitmap.createfromstream(lrstream);       lrstream.free;   end; end;  destructor tcard.destroy; begin   fcardback.free;   fcardset.free;   inherited; end;  procedure tcard.paint; var   lleft: single;   ltop: single; begin   inherited;   canvas.beginscene;   try     if fcarddown       canvas.drawbitmap(fcardback, trectf.create(0, 0, fcardback.width, fcardback.height), trectf.create(0, 0, width, height), 1.0)     else     begin       lleft := ord(fcardnum) * default_card_width;       ltop := ord(fcardsuit) * default_card_height;       canvas.drawbitmap(fcardset, trectf.create(lleft, ltop, lleft + default_card_width, ltop + default_card_height), trectf.create(0, 0, width, height), 1.0);     end;       canvas.endscene;   end; end; 

the solution add "property size;" on published too.

published   { published declarations }   property size;   property width;   property height; 

if add "height" , "width" work @ design-time.

thanks tried me.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -