Proportional form resizing lazarus / 31-LCL ---------------------------------------------------------------------- hukka · 2017-12-17 23:01 In my application I have a small window showing the preview of an image. I would like to be able to resize this form proportionally so as to keep it in the image's aspect ratio. What would be the best way to accomplish this, keeping cross-platform compatibility in mind? It seems like listening to the WM_SIZING message would be the way to go, but does this work on non-Windows platforms? Any code examples as to how to do this in FreePascal? Thanks, hukka ---------------------------------------------------------------------- jamie · 2017-12-17 23:41 The WM_SIZING would be the best but the form does not handle it.   I have an app that I do just that, I  keep the aspect while sizing the frame so when I grab the sides I can adjust the height and the same for the bottom.  processing the WM_SIZING works nicely because you can intercept the values and change them before they get used, otherwise you'll get flickering issues doing it with in the OnSize event.   You can do it in the OnSize event but care must be taken to not have it re-enter if you change the opposite sides to match, also you need to check which way its being sized. It gets tricky indeed. ---------------------------------------------------------------------- flowCRANE · 2017-12-18 00:25 @hukka: You can override the ChangeBounds method and modify the AWidth and AHeight params. Example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TForm1 = class(TForm)  protected    procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer; AKeepBase: Boolean); override;  end; procedure TForm1.ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer; AKeepBase: Boolean);begin  AWidth := AHeight; // form will always be square  inherited ChangeBounds(ALeft, ATop, AWidth, AHeight, AKeepBase);end; ---------------------------------------------------------------------- hukka · 2017-12-18 05:41 Quote from: furious programming on December 18, 2017, 01:25:30 am@hukka: You can override the ChangeBounds method and modify the AWidth and AHeight params. Perfect, thanks very much for your answer!