Monday, 15 September 2014

delphi - Save TPanel as image on disk -



delphi - Save TPanel as image on disk -

i have tpanel component on 1 of form.this panel has lots of children tlabel,timage,tline,tpanel etc.this panel used updated on timer. want capture screenshot of panel @ time. when utilize tpanel.makescreenshot showing children timage , tline. tlabels missing.

does body has thought how can achieved.

i using delphi xe5 , firemonkey.

thanks.

i had similar problem 1 time when making component capture contents of tlayout. in tests components not showing in screenshot taken tlayout.makescreenshot.

this due fact when create tlabel in code not automatically painted when parent tpanel. painted when shown first time. hence if this, label not show:

var newlabel: tlabel; shot: tbitmap; ... newlabel := tlabel.create; newlabel.parent := panel1; // suppose setting parent in code newlabel.text := 'some new label'; shot := panel1.makescreenshot;

to create labels show have create them paint on tpanel canvas. did applystylelookup method like:

... newlabel.text := 'some new label'; newlabel.applystylelookup; shot := panel1.makescreenshot; // label show

you have phone call applystylelookup each label create them appear.

it same if set autosize of tlabel true , set text. width of label not adjust before shown on form. haven't looked in detail in fmx source code, bug somewhere, because affects components.

you haven't shown code, i'm not sure if same problem, sure sounds it.

btw, know can't update fmx controls straight thread because not thread-safe, right? , free tbitmap returned makescreenshot?

delphi firemonkey delphi-xe5 firemonkey-fm2

No comments:

Post a Comment