Das Surface Pro 3 hat 216 PPI, deshalb die runde Verdoppelung der Größe (gegenüber normalen 96 DPI).
Wenn man es DPI-aware macht, werden Fontgrößen automatisch angepasst. Koordinaten (X, Y, Höhe, Breite) muß man aber,
je nach DPI auf dem System, skalieren. Ein kleines Beispiel dazu:
Code: Alles auswählen
Prototype proto_SetProcessDPIAware()
If OpenLibrary(0,"user32.dll")
SetProcessDPIAware.proto_SetProcessDPIAware = GetFunction(0,"SetProcessDPIAware")
If SetProcessDPIAware
;Debug "calling SetProcessDPIAware()"
SetProcessDPIAware() ; Windows Vista+ / Windows Server 2008+
EndIf
EndIf
Global _dpiScaleFactorX.d = GetDeviceCaps_(GetDC_(0),#LOGPIXELSX) / 96
Global _dpiScaleFactorY.d = GetDeviceCaps_(GetDC_(0),#LOGPIXELSY) / 96
Macro dpiX(_num_) : (_num_ * _dpiScaleFactorX) : EndMacro
Macro dpiY(_num_) : (_num_ * _dpiScaleFactorY) : EndMacro
; Load the font
t=LoadFont(1, "Arial", 10, #PB_Font_HighQuality) ;Load Arial Font, Size 10 - 28/NOV/2013
SetGadgetFont(#PB_Default, FontID(1))
If t=0 : MessageRequester("Error", "Can't load Arial font.") : EndIf
If OpenWindow(0, dpiX(0), dpiY(0), dpiX(640), dpiY(285), "DPIaware", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, dpiX(10),dpiY( 10),dpiX(200),dpiY(25), "Standard Button")
ButtonGadget(1, dpiX(10),dpiY( 40),dpiX(200),dpiY(25), "Left Button", #PB_Button_Left)
ButtonGadget(2, dpiX(10),dpiY( 70),dpiX(200),dpiY(25), "Right Button", #PB_Button_Right)
ButtonGadget(3, dpiX(10),dpiY(100),dpiX(200),dpiY(60), "Multiline Button (longer text gets automatically wrapped)", #PB_Button_MultiLine)
ButtonGadget(4, dpiX(10),dpiY(170),dpiX(200),dpiY(25), "Toggle Button", #PB_Button_Toggle)
ListViewGadget(5, dpiX(430),dpiY(10),dpiX(200),dpiy(185))
For i = 0 To 100 : AddGadgetItem(5,-1,"Item "+i) : Next
CanvasGadget(6, dpiX(220),dpiY(10),dpiX(200),dpiy(185))
If StartDrawing( CanvasOutput(6) )
Box(0,0,OutputWidth(),OutputHeight(),RGB($40,$40,$40))
Line(dpiX( 0) ,dpiY(0), dpiX(200),dpiy(185),RGB($FF,$FF,$00))
Line(dpiX(200),dpiY(0),-dpiX(200),dpiy(185),RGB($FF,$FF,$00))
StopDrawing()
EndIf
If LoadImage(0,#PB_Compiler_Home+"Examples/Sources/Data/PureBasicLogo.bmp")
ResizeImage(0,dpiX(ImageWidth(0)),dpiY(ImageHeight(0)))
ImageGadget(7,dpiX(10),dpiY(205),dpiX(381),dpiY(68),ImageID(0))
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Das hat auch absolut nichts mit "exklusiv Surface Pro 3" zu tun. Mit PB schreibst Du nur normale Windows-Desktop-Anwendungen, keine "Modern UI Apps".
Das gilt also überall, wo ein Monitor/Display mit mehr als 100% (96 DPI) verwendet wird. Oder auch allgemein, immer wenn der User die
Größenanpassung in den Systemeinstellungen auf mehr als 100% setzt. Bei dem Surface Pro 3 wird das bestimmt auf 200% eingestellt sein,
sonst erkennt man bei 2160 x 1440 auf 12 Zoll kaum noch etwas.