hi,

Anybody knows how to retrieve the maximum screen.height and width ?

I tried this :
_screen.windowstate = 2
nmaxwidth = _screen.width
...

but this flash the screen undesirably because the _screen is hidden in my
app.
and I don't want to flash it.

kind regards
christophe

Re: max screen resolution by Bernhard

Bernhard
Wed Apr 16 08:50:46 CDT 2008

Hi christophe,

in this newsgroup I once found the following solution.
Regards
Bernhard Sander

****************
* from microsoft.public.fox.programmer.exchange
* jacknospam@pebbleridge.com
* 17.01.2006
*****************************************

* Win API calls


* WinAPIGetMonRect
*
* Given a reference to a form, return the Top, Left, Width and Height of the
* monitor nearest to the form.
*
* lOK = WinAPIGetMonRect(oForm, @nLeft, @nTop, @nWidth, @nHeight)
*
* Returns .T. if no error

FUNCTION WinAPIGetMonRect

LPARAMETERS oForm, nLeft, nTop, nWidth, nHeight

LOCAL cRect, nHandle, cMonitorInfo

cRect = PADR('', 16, CHR(0)) && Place to store rect structure

DECLARE integer GetSystemMetrics IN WIN32API integer parm

IF GetSystemMetrics(80) > 1 && SM_CMONITORS
* Multiple monitors, MonitorFromRect and GetMonitorInfo must exist
* Note: Returns 0 on some older OSs that don't support multiple monitors
DECLARE integer MonitorFromRect IN WIN32API string @cRect, integer flags
DECLARE integer GetMonitorInfo IN WIN32API integer handle, string @cMonitorInfo

IF ! WinAPISetRect(@cRect, 0, oForm.Top, oForm.Left, oForm.Width, oForm.Height)
RETURN .F.
ENDIF

nHandle = MonitorFromRect(@cRect, 2)
IF nHandle == 0
RETURN .F.
ENDIF

cMonitorInfo = PADR('', 40, CHR(0))
IF ! WinAPISetInteger(@cMonitorInfo, 0, 4, 40)
RETURN .F.
ENDIF
IF GetMonitorInfo(nHandle, @cMonitorInfo) == 0
RETURN .F.
ENDIF

IF ! WinAPIGetRect(cMonitorInfo, 20, @nLeft, @nTop, @nWidth, @nHeight)
RETURN .F.
ENDIF
ELSE
* Only one monitor, OS might be too old for MonitorFromRect and GetMonitorInfo

DECLARE integer SystemParametersInfo IN WIN32API integer action, integer param,
string @struct, integer winini

IF SystemParametersInfo(48, 0, @cRect, 0) == 0 && SPI_GETWORKAREA
RETURN .F.
ENDIF

IF ! WinAPIGetRect(cRect, 0, @nLeft, @nTop, @nWidth, @nHeight)
RETURN .F.
ENDIF

ENDIF

RETURN .T.

ENDFUNC

************************************************************************************
* Support Routines
************************************************************************************


* WinAPIGetInteger
*
* Given a character string that contains a C struct, returns an integer from the
struct.
*
* nVal = WinAPIGetInteger(cStr, nOffset, nLen)
*
* cStr - the string
* nOffset - zero-based offset into the string of the start of the integer
* nLen - length of integer in bytes. Must be 1, 2, 3 or 4.
*
* Returns .NULL. if any input parameters are invalid

FUNCTION WinAPIGetInteger

LPARAMETERS cStr, nOffset, nLen

LOCAL nVal

IF nLen < 1 .OR. nLen > 4 .OR. nOffset < 0 .OR. nOffset + nLen > LEN(cStr)
RETURN .NULL.
ENDIF

nOffset = nOffset + nLen && Index of last byte (most significant)
nVal = 0
DO WHILE nLen > 0
nVal = BITLSHIFT(nVal, 8)
nVal = nVal + ASC(SUBSTR(cStr, nOffset, 1))
nOffset = nOffset - 1
nLen = nLen - 1
ENDDO

RETURN nVal

ENDFUNC


* WinAPISetInteger
*
* Given a character string that contains a C struct, stores an integer into the
struct.
*
* nVal = WinAPISetInteger(@cStr, nOffset, nLen, nVal)
*
* cStr - the string
* nOffset - zero-based offset into the string of the start of the integer
* nLen - length of integer in bytes. Must be 1, 2, 3 or 4.
* nVal - the value to store
*
* Returns .F. if any input parameters are invalid, else .T.

FUNCTION WinAPISetInteger

LPARAMETERS cStr, nOffset, nLen, nVal

LOCAL cStr1

IF nLen < 1 .OR. nLen > 4 .OR. nOffset < 0 .OR. nOffset + nLen > LEN(cStr)
RETURN .F.
ENDIF

cStr1 = ''

DO WHILE nLen > 0
cStr1 = cStr1 + CHR(BITAND(nVal, 255))
nLen = nLen - 1
nVal = BITRSHIFT(nVal, 8)
ENDDO

cStr = STUFF(cStr, nOffset+1, LEN(cStr1), cStr1)

RETURN .T.

ENDFUNC




* WinAPIGetRect
*
* Given a rect in a struct, break out the 4 parts
*
* WinAPIGetRect(cStruct, nOffset, @nLeft, @nTop, @nWidth, @nHeight)
*
* nOffset if the zero-based offset into the struct of the start of the rect
*
* Returns .F. if nOffset is not valid

FUNCTION WinAPIGetRect

LPARAMETERS cStruct, nOffset, nLeft, nTop, nWidth, nHeight

IF nOffset < 0 .OR. nOffset + 16 > LEN(cStruct)
RETURN .F.
ENDIF

nTop = WinAPIGetInteger(cStruct, nOffset+4, 4)
nLeft = WinAPIGetInteger(cStruct, nOffset+0, 4)

nHeight = WinAPIGetInteger(cStruct, nOffset+12, 4) - nTop
nWidth = WinAPIGetInteger(cStruct, nOffset+8, 4) - nLeft

RETURN .T.

ENDFUNC




* WinAPISetRect
*
* Given a rect in a struct, fill in the 4 parts
*
* WinAPISetRect(cStruct, nOffset, nLeft, nTop, nWidth, nHeight)
*
* nOffset if the zero-based offset into the struct of the start of the rect
*
* Returns .F. if nOffset is not valid

FUNCTION WinAPISetRect

LPARAMETERS cStruct, nOffset, nLeft, nTop, nWidth, nHeight

IF nOffset < 0 .OR. nOffset + 16 > LEN(cStruct)
RETURN .F.
ENDIF

IF TYPE('nLeft') == 'N'
WinAPISetInteger(@cStruct, nOffset+4, 4, nLeft)
IF TYPE('nWidth') == 'N'
WinAPISetInteger(@cStruct, nOffset+8, 4, nLeft + nWidth)
ENDIF
ENDIF

IF TYPE('nTop') == 'N'
WinAPISetInteger(@cStruct, nOffset+0, 4, nTop)
IF TYPE('nHeight') == 'N'
WinAPISetInteger(@cStruct, nOffset+12, 4, nTop + nHeight)
ENDIF
ENDIF

RETURN .T.

ENDFUNC

Re: max screen resolution by Gregory

Gregory
Wed Apr 16 09:08:36 CDT 2008

#include "foxpro.h"

&& Screen
?sysmetric(SYSMETRIC_SCREENWIDTH)
?sysmetric(SYSMETRIC_SCREENHEIGHT )

&& What's left - after taskbar and/or sidebar
?sysmetric(SYSMETRIC_CLIENTWIDTH )
?sysmetric(SYSMETRIC_CLIENTHEIGHT)

Gregory
_

"christophe" <nothingtosend@empty.com> wrote in message
news:%23PrPnW8nIHA.4292@TK2MSFTNGP04.phx.gbl...
> hi,
>
> Anybody knows how to retrieve the maximum screen.height and width ?
>
> I tried this :
> _screen.windowstate = 2
> nmaxwidth = _screen.width
> ...
>
> but this flash the screen undesirably because the _screen is hidden in my
> app.
> and I don't want to flash it.
>
> kind regards
> christophe
>
>

--
Gregory
__


thanx by christophe

christophe
Wed Apr 16 09:27:22 CDT 2008

Christophe

"christophe" <nothingtosend@empty.com> schreef in bericht
news:%23PrPnW8nIHA.4292@TK2MSFTNGP04.phx.gbl...
> hi,
>
> Anybody knows how to retrieve the maximum screen.height and width ?
>
> I tried this :
> _screen.windowstate = 2
> nmaxwidth = _screen.width
> ...
>
> but this flash the screen undesirably because the _screen is hidden in my
> app.
> and I don't want to flash it.
>
> kind regards
> christophe
>
>