How do I make my GUI behave well when Windows font scaling is greater than 100%

Your settings in the .dfm file will be scaled up correctly, so long as Scaled is True. If you are setting dimensions in code then you need to scale them by Screen.PixelsPerInch divided by Form.PixelsPerInch. Use MulDiv to do this. function TMyForm.ScaleDimension(const X: Integer): Integer; begin Result := MulDiv(X, Screen.PixelsPerInch, PixelsPerInch); end; This is what … Read more

How to dynamically create controls aligned to the top but after other aligned controls?

Once again, DisableAlign and EnableAlign to the rescue: procedure TForm1.FormCreate(Sender: TObject); var I: Integer; P: TPanel; begin DisableAlign; try for I := 0 to 4 do begin P := TPanel.Create(Self); P.Caption := IntToStr(I); P.Align := alTop; P.Parent := Self; end; finally EnableAlign; end; end; Explanation: When alignment is enabled, every single addition of a control … Read more

Split a string into an array of strings based on a delimiter

you can use the TStrings.DelimitedText property for split an string check this sample program Project28; {$APPTYPE CONSOLE} uses Classes, SysUtils; procedure Split(Delimiter: Char; Str: string; ListOfStrings: TStrings) ; begin ListOfStrings.Clear; ListOfStrings.Delimiter := Delimiter; ListOfStrings.StrictDelimiter := True; // Requires D2006 or newer. ListOfStrings.DelimitedText := Str; end; var OutPutList: TStringList; begin OutPutList := TStringList.Create; try Split(‘:’, ‘word:doc,txt,docx’, … Read more

Delphi – moving overlapping TShapes

A ‘simple sample redesign’ per my comment follows. unit Unit4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; const NUM_TRIANGLES = 10; COLORS: array[0..12] of integer = (clRed, clGreen, clBlue, clYellow, clFuchsia, clLime, clGray, clSilver, clBlack, clMaroon, clNavy, clSkyBlue, clMoneyGreen); type TTriangle = record X, Y: integer; // bottom-left corner Base, Height: … Read more