how to find the screen resolution

A

active

I've been looking for a way to determine the DPI (PPI) of the screen.

I've found often the suggestion to use:

Dim height As Integer = My.Computer.Screen.Bounds.Height

Dim width As Integer = My.Computer.Screen.Bounds.Width

but that gives the total number of pixels not the DPI (which is usually 96
for pc's).



Can you tell me how to the DPIX and DPIY?





Thanks
 
R

redear

I've been looking for a way to determine the DPI (PPI) of the screen.

I've found often the suggestion to use:

Dim height As Integer = My.Computer.Screen.Bounds.Height

Dim width As Integer = My.Computer.Screen.Bounds.Width

but that gives the total number of pixels not the DPI (which is usually 96
for pc's).

Can you tell me how to the DPIX and DPIY?

Thanks
Try this:

Dim dspGraphics As Graphics
dspGraphics = Me.CreateGraphics ' Graphics for user's display
MsgBox(dspGraphics.DpiY)
MsgBox(dspGraphics.DpiX)
dspGraphics.Dispose()
 
A

active

Works for me!

Thanks


redear said:
Try this:

Dim dspGraphics As Graphics
dspGraphics = Me.CreateGraphics ' Graphics for user's display
MsgBox(dspGraphics.DpiY)
MsgBox(dspGraphics.DpiX)
dspGraphics.Dispose()
 
A

active

I had seen that before I posted but as far as I could tell it only showed
how to get the screen bounds (which is the size) not the DPI.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top