Resizing a Image to selection rectangle Delphi -
hi cant figure out why wont work. have image , selection , want image same size , position selection set code in timer:
procedure tfrmmainui.tmrupdatetimer(sender: tobject); var : integer; begin image1.width:=selection1.width; image1.height:=selection1.height; image1.position.x:=selection1.position.x; image1.position.y:=selection1.position.y; end;
but doesn't work.
what supposed happen image resizes selection , position follows selection. happens can move , resize selection , image stays , doesn't resize.
as @mike sutton pointed out in comments, should using ontrack
event of tselection
trigger updates image.
the documentation says:
the event handler of ontrack event called cyclically mousemove method while tselection object in process of moving or resizing.
write custom ontrack event handler perform specific action when tselection in process of moving or resizing.
you state in comment, components created dynamically @ runtime, rather on designtime surface. need assign handler in code. this:
selection1.ontrack := selectiontrack;
your event handler this:
procedure tfrmmainui.selectiontrack(sender: tobject); begin image1.width:=selection1.width; image1.height:=selection1.height; image1.position.x:=selection1.position.x; image1.position.y:=selection1.position.y; end;
you in comments need track selection changes number of linked images , selections. can modify event handler this:
procedure tfrmmainui.selectiontrack(sender: tobject); var selection: tselection; image: timage; begin selection := sender tselection; image := imagefromselection(selection);//you need implement function image.width:=selection.width; image.height:=selection.height; image.position.x:=selection.position.x; image.position.y:=selection.position.y; end;
image delphi firemonkey
No comments:
Post a Comment