I remember the days when I programmed in assembler and managed to work very fast having complete control of my programs and not endlessly banging my head on the windows wall when dealing with the Microsoft side of my software.
Below is an example of some code that is simply resizing a timage component sited on a tpanel in response to a redraw event.
With the proportional property in the timage component 'main_image' set to true, all I have to do is specify the height or the width of the image and Delphi will calculate the width and height respectively based on the aspect ratio.
However, I want to also set the top and left properties so that the image is centred in the tpanel - the centred property seems to have no effect.
with main_image do if (width>0) and (height>0) then begin left:=0; top:=0; t_width:=width; t_height:=height; panel_width:=image_panel.width; panel_height:=image_panel.height; if t_width>panel_width then begin width:=panel_width; t_height:=height; end  else if t_height>panel_height then begin  height:=panel_height;  t_width:=width; end else begin t_width:=picture.bitmap.width; t_height:=picture.bitmap.height; width:=t_width; height:=t_height; end; left:=(panel_width-t_width) div 2; top:=(panel_height-t_height) div 2; end;
In the situation when the image is taller than the panel 'panel_height' I set the height property of the image to the same height as the panel.
As you can see, in order to calculate the 'left' property of the image I need to know the new value for the width of the image.
The result however always is the same, even the value for the width of the image in the debug watch never changes when it is clear the width is reducing in size when I squash the form by dragging the top of the window down. Don't also forget, I am changing the height property of the component, not the image itself which is resized inside the component because the proportional property is set to true.
The reason I believe the width property is not immediately accessible is 1: the code is situated in the redraw event method and 2: I have to seal off the event to prevent recursion due to changes made to the properties of the image component.
This code is also not exactly complete. ATM it assumes the width of the image is always wider than the height, but that can be dealt with later. All I am asking for is a way to make the code above work so that I can reposition the left/top properties of the image based on changes made to the height or width.