screen dpi
Posted: Mon Nov 28, 2011 5:57 am
anyone know a short example to collect the actual screen/monitor dpi?
Code: Select all
Debug GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #LOGPIXELSX)Code: Select all
;retrieves the horizontal DPI of the desktop
Procedure.i Gui_GetDesktopDpiX()
Protected hDc.i
Protected hDpi.i
hDc = GetDC_(GetDesktopWindow_())
If hDc
hDpi = GetDeviceCaps_(hDc, #LOGPIXELSX)
ReleaseDC_(GetDesktopWindow_(), hDc)
EndIf
ProcedureReturn hDpi
EndProcedure
;retrieves the vertical DPI of the desktop
Procedure.i Gui_GetDesktopDpiY()
Protected hDc.i
Protected vDpi.i
hDc = GetDC_(GetDesktopWindow_())
If hDc
vDpi = GetDeviceCaps_(hDc, #LOGPIXELSY)
ReleaseDC_(GetDesktopWindow_(), hDc)
EndIf
ProcedureReturn vDpi
EndProcedure
Code: Select all
;resizes the 3D view window to the iPhone screen size
Procedure Gui_Resize3DWnd2iPhoneSize(Scale.f)
Protected Width.i
Protected Height.i
Protected RelationX.f
Protected RelationY.f
RelationX = Gui_GetDesktopDpiX() / #iPhone_xDpi
RelationY = Gui_GetDesktopDpiY() / #iPhone_yDpi
Width = #iPhone_Width * RelationX * Scale
Height = #iPhone_Height * RelationY * Scale
ResizeWindow(Gui_3DWnd\PbNum, #PB_Ignore, #PB_Ignore, Width, Height)
EndProcedure