Click here to Skip to main content
15,868,141 members
Home / Discussions / C#
   

C#

 
GeneralRe: how get dpi scale factor Pin
Richard MacCutchan22-Mar-22 23:30
mveRichard MacCutchan22-Mar-22 23:30 
GeneralRe: how get dpi scale factor Pin
Le@rner23-Mar-22 0:00
Le@rner23-Mar-22 0:00 
GeneralRe: how get dpi scale factor Pin
Richard MacCutchan23-Mar-22 0:23
mveRichard MacCutchan23-Mar-22 0:23 
GeneralRe: how get dpi scale factor Pin
Dave Kreskowiak23-Mar-22 2:49
mveDave Kreskowiak23-Mar-22 2:49 
GeneralRe: how get dpi scale factor Pin
Le@rner23-Mar-22 17:55
Le@rner23-Mar-22 17:55 
GeneralRe: how get dpi scale factor Pin
Dave Kreskowiak24-Mar-22 6:47
mveDave Kreskowiak24-Mar-22 6:47 
QuestionRe: how get dpi scale factor Pin
Eddy Vluggen22-Mar-22 23:45
professionalEddy Vluggen22-Mar-22 23:45 
AnswerRe: how get dpi scale factor Pin
JudyL_MD24-Mar-22 6:15
JudyL_MD24-Mar-22 6:15 
DPI scaling is not that simple.

Here's how I do it for WinForms apps:

First, your app needs to be DPI-aware. You set that by the manifest. You also set that with with the AutoScaleDimensions and AutoScaleMode properties on each form.

Second, if you're designing forms from within Visual Studio, you need to do it on a system that is using 100% as the scaling factor for the display. If you don't do this, step 3 doesn't work.

Third, you can now use
scaleFrom96 = this.DeviceDpi / 96.0
to calculate a multiplication factor for resizing those things manually that WinForms will not do for you. Be warned, it is very hit and miss what things will be scaled for you automatically and what things will not. Lots of testing required.

OR you punt it all and design on a system that matches the system the app will be running on.

Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

GeneralRe: how get dpi scale factor Pin
Randor 24-Mar-22 20:49
professional Randor 24-Mar-22 20:49 
QuestionPassword CAPS not Checking in my code Pin
N Mohamed rafi22-Mar-22 21:08
N Mohamed rafi22-Mar-22 21:08 
AnswerRe: Password CAPS not Checking in my code Pin
OriginalGriff22-Mar-22 21:10
mveOriginalGriff22-Mar-22 21:10 
GeneralRe: Password CAPS not Checking in my code Pin
N Mohamed rafi23-Mar-22 0:56
N Mohamed rafi23-Mar-22 0:56 
GeneralRe: Password CAPS not Checking in my code Pin
OriginalGriff23-Mar-22 1:18
mveOriginalGriff23-Mar-22 1:18 
GeneralRe: Password CAPS not Checking in my code Pin
Dave Kreskowiak23-Mar-22 2:46
mveDave Kreskowiak23-Mar-22 2:46 
GeneralRe: Password CAPS not Checking in my code Pin
N Mohamed rafi25-Mar-22 22:56
N Mohamed rafi25-Mar-22 22:56 
GeneralRe: Password CAPS not Checking in my code Pin
Dave Kreskowiak26-Mar-22 9:53
mveDave Kreskowiak26-Mar-22 9:53 
QuestionMysql Query Error Pin
N Mohamed rafi22-Mar-22 1:53
N Mohamed rafi22-Mar-22 1:53 
AnswerRe: Mysql Query Error Pin
Dave Kreskowiak22-Mar-22 2:02
mveDave Kreskowiak22-Mar-22 2:02 
AnswerRe: Mysql Query Error Pin
OriginalGriff22-Mar-22 2:40
mveOriginalGriff22-Mar-22 2:40 
Questionhow sort datgridview or listview like windows explorer Pin
Le@rner21-Mar-22 20:01
Le@rner21-Mar-22 20:01 
AnswerRe: how sort datgridview or listview like windows explorer Pin
OriginalGriff21-Mar-22 21:12
mveOriginalGriff21-Mar-22 21:12 
GeneralRe: how sort datgridview or listview like windows explorer Pin
Le@rner22-Mar-22 1:20
Le@rner22-Mar-22 1:20 
GeneralRe: how sort datgridview or listview like windows explorer Pin
Dave Kreskowiak22-Mar-22 1:50
mveDave Kreskowiak22-Mar-22 1:50 
AnswerRe: how sort datgridview or listview like windows explorer Pin
Richard Deeming21-Mar-22 22:32
mveRichard Deeming21-Mar-22 22:32 
GeneralRe: how sort datgridview or listview like windows explorer Pin
Le@rner22-Mar-22 2:00
Le@rner22-Mar-22 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.