delphi - TPanel does not AutoSize when containing a TPanel -
i have panel inside another:
the inner panel aligned altop
:
and outer panel set autosize=true
:
and sizes. if changes height of inner panel @ design time, outer panel auto sizes accommodate it:
and runtime
now need change height of inner panel @ runtime:
procedure tform2.button1click(sender: tobject); begin pnlinner.height := pnlinner.height + 50; lblpointer.top := pnlouter.top + pnlinner.height; end;
except when change height of inner panel @ runtime, autosize panel not autosize:
this of course worked in delphi 5, 7, , probably xe2 - xe5.
what's fix?
the workaround is, of course, bypass alignment/autosize , during various onresize events. that's distinctly not rad. i'm sure it's small bug in vcl somewhere. , since have two-dozen xe6 vcl bugs we've patched, better fix nobody else has think it.
bonus chatter
i love line:
and, please attach sample project?
it's if nobody bothered try reproduce it.
the issue regression in twincontrol.aligncontrols:
procedure twincontrol.aligncontrols(acontrol: tcontrol; var rect: trect); begin //...snip // apply constraints if showing , ((sfwidth in fscalingflags) or (sfheight in fscalingflags)) doadjustsize; //...snip end;
the bug here not call doadjustsize
unless either sfwidth or sfheight scaling flags present.
the fix not try outsmart yourself, , doadjustsize
regardless:
procedure twincontrol.aligncontrols(acontrol: tcontrol; var rect: trect); begin //...snip // apply constraints //qc125995: don't scaling flags decide if should adjust size if showing {and ((sfwidth in fscalingflags) or (sfheight in fscalingflags))} doadjustsize; //...snip end;
with fix found, we're halfway solving the similar issue except tolecontrol (e.g. twebbrowser
) rather tpanel.
note: code released public domain. no attribution required.
Comments
Post a Comment