How to internally deal with custom ppi?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38142
    kaju_74
    Participant

    Hi,

    I'm playing with the CustomPPI settings in my app and have a problem if I try to save & restore used windows dimensions & fonts. After the form has been shown, I persist the actual setted font (for an embedded editor) as well as the properties “Height” & “Width” of the form. If this form is loaded the next time, I'll read the previously written settings and initialize the corresponding properties (Font.Size, Height & Width).

    This works fine with the default scaling (ppi). As soon as I use a custom ppi, all settings will be saved with larger values than they realy are – e.g. my form will be widther & heigher each time and the font is scalled up every time.

    I've logged the width value before & after showing the form and due of the AlphaSkin scaling, the width property is (for example) 100pixels larger than before. It seems, AlphaSkin increases this kind of properties for the scaling process but didn't restore them before the form is closing.

    Is there any way to retrieve the 'real' values which could be saved for further calls to this form?

    Regards,

    kaju

    #59038
    Support
    Keymaster

    Hello

    Look, maybe this code can help you to save original size:

    Code:
    uses sSkinManager, sVclUtils;

    var
    iPPI: integer;

    if DefaultManager.IsActive then begin
    if DefaultManager.Options.ScaleMode = smVCL then
    iPPI := DefaultPPI
    else
    iPPI := DefaultManager.Options.PixelsPerInch
    end
    else
    iPPI := 96;

    SaveMainFormWidthHeight(Width * 96 div iPPI, Height * 96 div iPPI);

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.