C#C
C#3y ago
4 replies
uselessxp

✅ WPF - Detect if screen resolution is resized (ex. 125% or more)

I'm writing a tool in which I need to first set the screen resolution, I currently have a 1920 x 1080, but I noticed that if in Windows screen resolution I enable the automatic resizing to 125% (or more) the tool retrieve false values.

Ex. for 125% the software think that my resolution is: 1536 x 864.
Is there an easy way to detect if is this enabled, and maybe also detect the % value?
I'd like to make something like that.

private void Button_Click(object sender, RoutedEventArgs e)
{
    bool isResizing = true;
    if (isResizing)
    {
        MessageBox.Show((SystemParameters.PrimaryScreenWidth * 1.25).ToString());
        MessageBox.Show((SystemParameters.PrimaryScreenHeight * 1.25).ToString());
    }
    else
    {
        MessageBox.Show((SystemParameters.PrimaryScreenWidth).ToString());
        MessageBox.Show((SystemParameters.PrimaryScreenHeight).ToString());
    }
}


Or better:
int resizingPercent = 25;


If it's possible it will be nice, if it's not possible or too hard to make I'll go to ask to the user those data.
Was this page helpful?