Geting wrong DesktopWidth for Larger 150% DPI

BlitzMax Forums/BlitzMax Programming/Geting wrong DesktopWidth for Larger 150% DPI

Afke(Posted 2012) [#1]
Hi guys,

On BigFish request I have to solve resolution problem for Larger 150% DPI.

I found out Blitzmax returning invalid current resolution with DesktopWidth() and DesktopHeight()
For example :
For resolution 1680x1050 DesktopWidth()= 1120 DesktopHeight()=700

I can eventually calculate valid resolution but how can I get current DPI information?

if I try to make Graphics(1680,1050) it works!

But I don't want to mess with that. To guess which resolution to use on which machine . That is biggest pain I ever had. And believe me that could reproduce a tons of bugs.

Thanks in advance


Jesse(Posted 2012) [#2]
I don't know but have you tried it with desktop extension:

http://www.chaos-interactive.de/en/desktopextension/


Afke(Posted 2012) [#3]
Thanks

But same :(


matibee(Posted 2012) [#4]
I don't have the answer Afke but I suspect you can call the relevant Windows API functions from within your Blitmax code...

http://msdn.microsoft.com/en-us/library/windows/desktop/dd756596%28v=vs.85%29.aspx

that's the normal approach to OS specific problems.

Hope that helps.


Afke(Posted 2012) [#5]
Thanks I will try :)


Afke(Posted 2012) [#6]
Strange I made it and then I found out that BlitzMax calculate same thing corect. DesktopWidth() returning corect value on 125% but fails on 150%

I found out that problem is not in the BlitzMax ,Win Method GetDeviceCaps(hdc, LOGPIXELSX) returning wrong value.

100% dpi=96
125% dpi=120
150% dpi=96 :)

Last edited 2012


Afke(Posted 2012) [#7]
There is a my code :

SuperStrict


Print DesktopDpiX()
Print DesktopDpiY()

Function DesktopDpiX:Int()
	?Win32
	Local hwnd:Int = GetDesktopWindow()
	Local hdc:Int = GetDC(hwnd)
	Return GetDeviceCaps(hdc, LOGPIXELSX)
	?
End Function

Function DesktopDpiY:Int()
	?Win32
	Local hwnd:Int = GetDesktopWindow()
	Local hdc:Int = GetDC(hwnd)
	Return GetDeviceCaps(hdc, LOGPIXELSY)
	?
End Function



Last edited 2012

Last edited 2012

Last edited 2012


col(Posted 2012) [#8]
Hiya.

This is actually the normal behavior for when programs written for Vista upwards don't conform to what Microsoft actually say should be done when writing programs for their OS(s).

Ultimately you'll need a manifest file.

Following this link and also this link too should help resolve your issue.

EDIT:- My advise would be for people to always either include a manifest file as a '.o resource' or use a separate file along side the .exe, ie- myfile.exe.manifest in the same directory.

If you choose the external manifest method then you need to consider that it matters whether the manifest file is created before or after the .exe file. I can't remember the order now as I always 'Import' it as a .o file.

EDIT again:- I believe the BLIde BlitzMax editor made by Ziggy has the option to include a manifest file thus making the whole process real simple.

Last edited 2012


Afke(Posted 2012) [#9]
Thanks Col.


Grey Alien(Posted 2012) [#10]
Why are you checking the DPI anyway?


Afke(Posted 2012) [#11]
Hey Grey Alien,

Because DesktopWidth() and DesktopHeight() returning wrong width and height value when you set Larger 150% DPI setting on windows 7, but it works for 125%. I use that to check what is the current desktop resolution for my resolution logic . So I have some bugs, on some machines like

DPI 150% - Windowed Mode - Game crashes and requires Task Kill if Windowed mode is attempted while at DPI 150%
or
Graphic corruption occurs

:) ROCK N ROLL

EDIT : Including manifest solve the problem.

Last edited 2012