Jump to content
Mark Billig

Application Position & Size

Recommended Posts

I got tired of positioning applications on my remote screen.  With RDP's full bar that appears in the top center nicely covering Outlook's search window.  I decided I needed a tool to make it easier, APS.  To select the application that I want to gather position and size info from or position an application I borrowed a component comp.reticle.  I have it working but it is not scaling properly.  I am trying to modify comp.reticle to handle the changing DPI.




The targets on the left were placed in from the IDE designer.  The targets on the right were added at runtime.  I am trying to figure out why it is different with the same component.

Share this post

Link to post

Short answer, during form create a scale to dpi is done.  If you create the controls after that method, you have to re-size them for dpi.

Try Vcl.Controls.TControl.ScaleForPPI

  • Like 1

Share this post

Link to post

Thank you that helped.  I tried to adjust the Width & Height of the WindowReticle component but it still does not look like the right size.  Also is there a way to get the DPI variable from a system variable?


procedure TMainForm.AddGetSetFrame;
  TmpDPI: Integer;
  TmpDPI := 96;
  SetLength(GetSetFrameA, Length(GetSetFrameA) + 1);
  GetSetFrameA[High(GetSetFrameA)] := TGetSetFrame.Create(FrameScrollBox);
  with GetSetFrameA[High(GetSetFrameA)] do
    Parent := FrameScrollBox;
    Top := High(GetSetFrameA) * Height + 5;
    Align := alTop;
    Name := 'GetSetFrame_' + IntToStr(High(GetSetFrameA));
    Tag := High(GetSetFrameA);
    PopupMenu := GSFramePopupMenu;

    // Get
    GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Left := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Left, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Top := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Top, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Width := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Width, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Height := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.Height, Screen.PixelsPerInch, TmpDPI);

    // Set
    GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Left := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Left, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Top := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Top, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Width := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Width, Screen.PixelsPerInch, TmpDPI);
    GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Height := MulDiv(GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.Height, Screen.PixelsPerInch, TmpDPI);


Computer scale set at 100%



Computer scale set at 150%


Share this post

Link to post

TFrame should have CurrentPPI.


To me that frame should be using grid panel (aligned client) with 3 columns, nest a grid panel in the 2nd column to layout all those number / spin edits. 


Let the grid panel / alignment / align with margins do the work, the re-sizing gets a lot more natural after that. 

Share this post

Link to post

It's not a good idea to use Screen.PixelsPerInch, with per-monitor DPI it will not work correctly on multi monitor setup with different dpi.

Share this post

Link to post

I got it figured out.  One of the problems was the WindowReticle was configured CanResize = False.  Thank you again for all of your help.  I need to post my updates to GitHub.



Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now