Mr. Frose
Nice approach
We will adopt that with very minor modifications.
We will post the revised code here for your testing
We will post the revised code here for your testing
function FW_GetMonitor( nRow, nCol ) // POINT r,c [OR] nMonitor, [or] oWnd/hWnd No params: primary monitor
local aInfo, oMonitor, x, y, nMonitor, nMax, hWnd, aRect
if nRow == nil .and. nCol == nil
oMonitor := TMonitor():New( MonitorInfoFromRC( 20, 20 ) )
elseif HB_ISNUMERIC( nRow ) .and. HB_ISNUMERIC( nCol )
aInfo := MonitorInfoFromRC( nRow, nCol )
if !Empty( aInfo )
oMonitor := TMonitor():New( aInfo )
endif
elseif PCount() == 1
if HB_ISOBJECT( nRow ) .and. nRow:IsKindOf( "TWINDOW" )
nRow := nRow:hWnd
endif
if ValType( nRow ) != "N"
nRow := 1
endif
if IsWindow( nRow )
aInfo := MonitorInfoFromRC( nRow )
if aInfo != nil
oMonitor := TMonitor():New( aInfo )
endif
else
nMax := Max( 1, Min( nRow, FW_ActiveMonitors() ) )
aRect := FW_VirtualScreen()
x := aRect[ 2 ] + 100
for nMonitor := 1 to nMax
for y := aRect[ 1 ] + 100 to aRect[ 3 ] step 100
aInfo := MonitorInfoFromRC( y, x )
if !Empty( aInfo )
EXIT
endif
next
if Empty( aInfo ) // should not happen
return nil
endif
x := aInfo[ 4 ] + 100
next nMonitor
oMonitor := TMonitor():New( aInfo )
endif
endif
return oMonitor
function FW_GetAllMonitors()
local aMonitors := {}
local aRect, x, y, aInfo, nMonitors, nMonitor
nMonitors := FW_ActiveMonitors()
aRect := FW_VirtualScreen()
x := aRect[ 2 ] + 100
do while x < aRect[ 4 ]
aInfo := nil
for y := aRect[ 1 ] + 100 to aRect[ 3 ] step 100
aInfo := MonitorInfoFromRC( y, x )
if !Empty( aInfo )
EXIT
endif
next
if Empty( aInfo )
EXIT
endif
AAdd( aMonitors, TMonitor():New( aInfo ) )
x := aInfo[ 4 ] + 100
enddo
return aMonitors
- Nothing found about oMonitor:lWinRect, what is the purpose of it?
- What is the aim of oMonitor:cRect? Do you want to fill it with ArraysString( aRect ), I would appreciate it
- It would be helpful to integrate the Array rcWork in the class TMonitor, to get the information where the task bar(s) are nested
function FW_GetAllMonitors()
local aMonitors := {}
local aRect, nRow, nCol, aInfo, caInfo, nMonitors, nMonitor := 0
nMonitors := FW_ActiveMonitors()
aRect := FW_VirtualScreen()
for nRow := aRect[ 1 ] + 100 to aRect[ 3 ] step 100
for nCol := aRect[ 2 ] + 100 to aRect[ 4 ] step 100
aInfo := MonitorInfoFromRC( nRow, nCol )
IF HB_IsArray( aInfo )
caInfo := Str( aInfo[ 1 ] ) + ", " + Str( aInfo[ 2 ] ) + ", " + Str( aInfo[ 3 ] ) + ", " + Str( aInfo[ 4 ] )
IF AScan( aMonitors, { | x | x[ 2 ] == caInfo } ) == 0
nMonitor ++
AAdd( aMonitors, { nMonitor, caInfo, aInfo, TMonitor():New( aInfo ) } )
ENDIF
ENDIF
IF nMonitor >= nMonitors
EXIT
ENDIF
next nCol
IF nMonitor >= nMonitors
EXIT
ENDIF
next nRow
return aMonitors
STATIC aMonitors_static
function FW_GetMonitor( nRow, nCol ) // POINT r,c [OR] nMonitor, [or] oWnd/hWnd No params: primary monitor
...
else
IF HB_IsNIL( aMonitors_static )
aMonitors_static := FW_GetAllMonitors()
ENDIF
oMonitor := aMonitors_static[ nRow, 4 ]
endif
...
return oMonitor
What are the 3 Rects you are getting with your function?
cRect is formatted like C Language RECT struct to be directly used with Windows API functions.
This is not of use in application programs.
post scriptum: If I find the time, I will test the functions with 4 displays in a very strange order later this WE, I'll give you an info about the results
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 39 guests