Click here to Skip to main content
15,900,714 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
fjparisIII20-Jul-09 8:40
fjparisIII20-Jul-09 8:40 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
Luc Pattyn20-Jul-09 8:48
sitebuilderLuc Pattyn20-Jul-09 8:48 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
fjparisIII20-Jul-09 12:13
fjparisIII20-Jul-09 12:13 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
Luc Pattyn20-Jul-09 12:32
sitebuilderLuc Pattyn20-Jul-09 12:32 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
fjparisIII20-Jul-09 13:31
fjparisIII20-Jul-09 13:31 
GeneralRe: How to get DPI Scaling number within .NET Framework Pin
Luc Pattyn20-Jul-09 14:00
sitebuilderLuc Pattyn20-Jul-09 14:00 
AnswerRe: How to get DPI Scaling number within .NET Framework Pin
Luc Pattyn20-Jul-09 11:42
sitebuilderLuc Pattyn20-Jul-09 11:42 
AnswerRe: How to get DPI Scaling number within .NET Framework (SOLVED) Pin
fjparisIII21-Jul-09 11:16
fjparisIII21-Jul-09 11:16 
I got the answer from the WPF forum, where I cross-posted. Here is the code, and it is indeed WPF-specific as I knew it would have to be after getting a suggestion from a Windows Forms programmer on this forum. It is actually much more elegant than the Forms suggestion, one more indication of the superiority of WPF over Windows Forms. It is device-specific! So if Microsoft ever does get around to supporting individual DPI Scalings per monitor, this code will work without change.

Consider the following code snippet:

// Find out which monitor the ViewerWindow should be on.
_left = Monitor.Rect.left;
_top = Monitor.Rect.top;
_width = Monitor.Width;
_height = Monitor.Height;
//
// Account for the DPI scaling of this monitor.
Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
double dpiX = m.M11;
double dpiY = m.M22;
_left /= dpiX;
_top /= dpiY;
_width /= dpiX;
_height /= dpiY;

The original values of _left, _top, _width and _height are the direct result of the monitor properties of the monitor the code is going to display images on. dpiX and dpiY are then the DPI scaling factors of the X and Y directions of that monitor. for 96 DPI (the standard) the values are 1.0. For 120 DPI, the values are 1.25. So I just scale the four monitor dimensions and Voila! Absolute perfection for this particular monitor.

End of story.
QuestionUnderstanding HandleRef Pin
stax7620-Jul-09 4:29
stax7620-Jul-09 4:29 
AnswerRe: Understanding HandleRef Pin
Eddy Vluggen20-Jul-09 6:25
professionalEddy Vluggen20-Jul-09 6:25 
GeneralRe: Understanding HandleRef Pin
stax7620-Jul-09 6:47
stax7620-Jul-09 6:47 
GeneralRe: Understanding HandleRef Pin
Eddy Vluggen20-Jul-09 9:18
professionalEddy Vluggen20-Jul-09 9:18 
GeneralRe: Understanding HandleRef Pin
stax7620-Jul-09 9:35
stax7620-Jul-09 9:35 
GeneralRe: Understanding HandleRef Pin
Eddy Vluggen20-Jul-09 10:16
professionalEddy Vluggen20-Jul-09 10:16 
QuestionThe remote server returned an error: (403) Forbidden." Pin
nkmkrishna20-Jul-09 2:45
nkmkrishna20-Jul-09 2:45 
AnswerRe: The remote server returned an error: (403) Forbidden." Pin
Adam R Harris21-Jul-09 10:05
Adam R Harris21-Jul-09 10:05 
AnswerRe: The remote server returned an error: (403) Forbidden." Pin
veerasekar vallambar15-Jun-10 4:49
veerasekar vallambar15-Jun-10 4:49 
Question"........make sure u've not released resources before trying to use it"???? Pin
ChiSmile20-Jul-09 0:46
ChiSmile20-Jul-09 0:46 
AnswerRe: "........make sure u've not released resources before trying to use it"???? Pin
Gideon Engelberth20-Jul-09 3:25
Gideon Engelberth20-Jul-09 3:25 
GeneralRe: "........make sure u've not released resources before trying to use it"???? Pin
ChiSmile20-Jul-09 5:50
ChiSmile20-Jul-09 5:50 
GeneralRe: "........make sure u've not released resources before trying to use it"???? Pin
Gideon Engelberth20-Jul-09 12:00
Gideon Engelberth20-Jul-09 12:00 
QuestionRetrieve node texts from treenode Pin
vidhyaravichandar19-Jul-09 22:16
vidhyaravichandar19-Jul-09 22:16 
AnswerRe: Retrieve node texts from treenode Pin
Lee Humphries20-Jul-09 11:39
professionalLee Humphries20-Jul-09 11:39 
GeneralRe: Retrieve node texts from treenode Pin
vidhyaravichandar20-Jul-09 15:53
vidhyaravichandar20-Jul-09 15:53 
QuestionHow to include xml Pin
ksss_maheshece19-Jul-09 21:15
ksss_maheshece19-Jul-09 21:15 

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.