Mark Billig 0 Posted September 12, 2022 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
SwiftExpat 65 Posted September 13, 2022 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 1 Share this post Link to post
Mark Billig 0 Posted September 13, 2022 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; var TmpDPI: Integer; begin TmpDPI := 96; SetLength(GetSetFrameA, Length(GetSetFrameA) + 1); GetSetFrameA[High(GetSetFrameA)] := TGetSetFrame.Create(FrameScrollBox); with GetSetFrameA[High(GetSetFrameA)] do begin 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); GetSetFrameA[High(GetSetFrameA)].GSGetWindowReticle.ScaleForPPI(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); GetSetFrameA[High(GetSetFrameA)].GSSetWindowReticle.ScaleForPPI(TmpDPI); end; end; Computer scale set at 100% Computer scale set at 150% Share this post Link to post
SwiftExpat 65 Posted September 13, 2022 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
Lajos Juhász 293 Posted September 14, 2022 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
Mark Billig 0 Posted September 14, 2022 Do you have a recommendation of what I should use in place of Screen.PixelsPerInch? Share this post Link to post
Lajos Juhász 293 Posted September 14, 2022 In this case I would go with Form.CurrentPPI (Every control has a CurrentPPI property). Share this post Link to post
Mark Billig 0 Posted September 16, 2022 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
Mark Billig 0 Posted September 16, 2022 https://github.com/mbillig02/APS Share this post Link to post