SilverpointDev / sptbxlib

SpTBXLib is an expansion package for TB2K Delphi components that adds multiple features including support for styles and custom skins.
https://www.silverpointdevelopment.com
Other
73 stars 33 forks source link

TSpTBXFormPopupMenu doesn't reflect changes of width and height of the assigned PopupForm #111

Closed LihemdiRachid closed 1 year ago

LihemdiRachid commented 1 year ago

(Migrating a BDS2006 & SpTBXLib 2.4.5 to Delphi 10.4 & SpTBXLib 2.5.10)

  1. Create a new VLC Application, Form1 is created by default

  2. Add SpTBXFormPopupMenuthe in the uses section

  3. Declare a private variable of Form1:

    popFrm: TSpTBXFormPopupMenu;
  4. Add a new form, Form2 is created.

  5. Give a size to Form2 of, let's say, 400x600

  6. In Form1, drop a Button, and on its OnClick event, put the following code

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if not Assigned(popFrm) then
        popFrm := TSpTBXFormPopupMenu.Create(Self);
    if not Assigned(Form2) then
        Form2 := TForm2.Create(Self);
    Form2.Height := 200;
    Form2.Width := 200;
    popFrm.PopupForm := Form2;
    popFrm.Popup(Self.Left, Self.Top);
    end;
  7. Run the app and click the button, Form2 is popped up, but not in 200x200. It keeps its design size. The exact same code works fine in BDS2006

The issue has been introduced with the call to ScaleForPPI in TSpTBXFormPopupMenu.InternalPopup

SilverpointDev commented 1 year ago

Change this in TSpTBXFormPopupMenu.InternalPopup:

      TCustomFormAccess(FPopupForm).ScaleForPPI(PPI);
      FWrapperForm.ScaleForPPI(PPI);

To:

    if PPI <> TCustomFormAccess(FPopupForm).CurrentPPI then begin
      TCustomFormAccess(FPopupForm).ScaleForPPI(PPI);
      FWrapperForm.ScaleForPPI(PPI);
    end;
LihemdiRachid commented 1 year ago

Thanks for the quick reaction! I confirm it solves the issue. Tested under the following conditions:

Thanks a lot!

LihemdiRachid commented 1 year ago

Just tested with DPI Awareness = Per Monitor V2 ==> Fails With the test in the original post, designed in 96 dpi

Just to let you know, as I don't use Per Monitor yet in my application

SilverpointDev commented 1 year ago

Try the latest commit