Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get screen resolution
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Get screen resolution
Divers
Thread ID:
00471746
Message ID:
00471746
Vues:
57
Hello,
I figured out a way to get the screen resolution for the device, using GetDeviceCaps in Gdi32.dll.

Maybe someone is interested, or someone may like to put it in the API lib (I do not know how to do this), or someone has a better way of doing this.

Here is an example:

PROCEDURE GetScreenResolution
*-- Create an object:
LOCAL loScreenResolution
loScreenResolution = NEWOBJECT("Relation")
*
WITH loScreenResolution
.ADDPROPERTY("Horizontal", 0)
.ADDPROPERTY("Vertical", 0)
.ADDPROPERTY("HorzResConstant", 8)
.ADDPROPERTY("VertResConstant", 10)
.ADDPROPERTY("ActiveWindow", 0)
.ADDPROPERTY("DeviceContext", 0)
ENDWITH
*
*-- Get a handle on the active window.
DECLARE INTEGER GetActiveWindow IN Win32API
loScreenResolution.ActiveWindow = GetActiveWindow()
*
DECLARE INTEGER GetDCEx IN User32.dll INTEGER, INTEGER, INTEGER
loScreenResolution.DeviceContext = GetDCEx(loScreenResolution.ActiveWindow, 0, 0)
DECLARE INTEGER GetDeviceCaps IN Gdi32.dll INTEGER, INTEGER
*
*-- The api calls.
loScreenResolution.Horizontal = GetDeviceCaps(loScreenResolution.DeviceContext, loScreenResolution.HorzResConstant)
loScreenResolution.Vertical = GetDeviceCaps(loScreenResolution.DeviceContext, loScreenResolution.VertResConstant)
*
*-- The result.
?loScreenResolution.Horizontal
?loScreenResolution.Vertical
*
ENDPROC

You can use this function to return other values, using different constants like those:

' Device Parameters for GetDeviceCaps()
Public Const DRIVERVERSION = 0 ' Device driver version
Public Const TECHNOLOGY = 2 ' Device classification
Public Const HORZSIZE = 4 ' Horizontal size in millimeters
Public Const VERTSIZE = 6 ' Vertical size in millimeters
Public Const HORZRES = 8 ' Horizontal width in pixels
Public Const VERTRES = 10 ' Vertical width in pixels
Public Const BITSPIXEL = 12 ' Number of bits per pixel
Public Const PLANES = 14 ' Number of planes
Public Const NUMBRUSHES = 16 ' Number of brushes the device has
Public Const NUMPENS = 18 ' Number of pens the device has
Public Const NUMMARKERS = 20 ' Number of markers the device has
Public Const NUMFONTS = 22 ' Number of fonts the device has
Public Const NUMCOLORS = 24 ' Number of colors the device supports
Public Const PDEVICESIZE = 26 ' Size required for device descriptor
Public Const CURVECAPS = 28 ' Curve capabilities
Public Const LINECAPS = 30 ' Line capabilities
Public Const POLYGONALCAPS = 32 ' Polygonal capabilities
Public Const TEXTCAPS = 34 ' Text capabilities
Public Const CLIPCAPS = 36 ' Clipping capabilities
Public Const RASTERCAPS = 38 ' Bitblt capabilities
Public Const ASPECTX = 40 ' Length of the X leg
Public Const ASPECTY = 42 ' Length of the Y leg
Public Const ASPECTXY = 44 ' Length of the hypotenuse
Christian Isberner
Software Consultant
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform