#include "FiveWin.ch"
function Main()
EnumDisplayMonitors( { | nMonitor, hMonitor, hdcMonitor, lPrimary, aMonitorRect, aMonitorRectInfo, aWorkRect | ;
XBrowser( { "nMonitor" => nMonitor,;
"hMonitor" => hMonitor,;
"hdcMonitor" => hdcMonitor,;
"lPrimary" => lPrimary,;
"aMonitorRect" => aMonitorRect,;
"aMonitorRectInfo" => aMonitorRectInfo,;
"aWorkRect" => aWorkRect } ), .T. } ) // .T. continue to next monitor
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <hbapiitm.h>
static int iMonitorCount;
static BOOL CALLBACK MonitorEnumProc( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
{
MONITORINFOEX mi;
if( iMonitorCount >= MAX_MONITORS )
{
return FALSE; // Stop enumeration if we've reached the maximum
}
mi.cbSize = sizeof( MONITORINFOEX );
if( GetMonitorInfo( hMonitor, ( LPMONITORINFO ) &mi ) )
{
PHB_ITEM pMonitorCount = hb_itemPutNL( NULL, ++iMonitorCount );
PHB_ITEM pHandleMonitor = hb_itemPutPtr( NULL, hMonitor );
PHB_ITEM phdcMonitor = hb_itemPutPtr( NULL, hdcMonitor );
PHB_ITEM prctMonitor = hb_itemArrayNew( 4 );
PHB_ITEM pIsPrimary = hb_itemPutL( NULL, ( mi.dwFlags & MONITORINFOF_PRIMARY) != 0 );
PHB_ITEM prctMonitorInfo = hb_itemArrayNew( 4 );
PHB_ITEM prctWork = hb_itemArrayNew( 4 );
PHB_ITEM pMonitorLeft = hb_itemPutNL( NULL, lprcMonitor->left );
PHB_ITEM pMonitorTop = hb_itemPutNL( NULL, lprcMonitor->top );
PHB_ITEM pMonitorBottom = hb_itemPutNL( NULL, lprcMonitor->bottom );
PHB_ITEM pMonitorRight = hb_itemPutNL( NULL, lprcMonitor->right );
PHB_ITEM pMonitorInfoLeft = hb_itemPutNL( NULL, mi.rcMonitor.left );
PHB_ITEM pMonitorInfoTop = hb_itemPutNL( NULL, mi.rcMonitor.top );
PHB_ITEM pMonitorInfoBottom = hb_itemPutNL( NULL, mi.rcMonitor.bottom );
PHB_ITEM pMonitorInfoRight = hb_itemPutNL( NULL, mi.rcMonitor.right );
PHB_ITEM pWorkLeft = hb_itemPutNL( NULL, mi.rcWork.left );
PHB_ITEM pWorkTop = hb_itemPutNL( NULL, mi.rcWork.top );
PHB_ITEM pWorkBottom = hb_itemPutNL( NULL, mi.rcWork.bottom );
PHB_ITEM pWorkRight = hb_itemPutNL( NULL, mi.rcWork.right );
hb_itemArrayPut( prctMonitor, 1, pMonitorLeft );
hb_itemArrayPut( prctMonitor, 2, pMonitorTop );
hb_itemArrayPut( prctMonitor, 3, pMonitorBottom );
hb_itemArrayPut( prctMonitor, 4, pMonitorRight );
hb_itemArrayPut( prctMonitorInfo, 1, pMonitorInfoLeft );
hb_itemArrayPut( prctMonitorInfo, 2, pMonitorInfoTop );
hb_itemArrayPut( prctMonitorInfo, 3, pMonitorInfoBottom );
hb_itemArrayPut( prctMonitorInfo, 4, pMonitorInfoRight );
hb_itemArrayPut( prctWork, 1, pWorkLeft );
hb_itemArrayPut( prctWork, 2, pWorkTop );
hb_itemArrayPut( prctWork, 3, pWorkBottom );
hb_itemArrayPut( prctWork, 4, pWorkRight );
hb_evalBlock( ( PHB_ITEM ) dwData, pMonitorCount, pHandleMonitor, phdcMonitor, pIsPrimary, prctMonitor,
prctMonitorInfo, prctWork, NULL );
hb_itemRelease( pMonitorLeft );
hb_itemRelease( pMonitorTop );
hb_itemRelease( pMonitorBottom );
hb_itemRelease( pMonitorRight );
hb_itemRelease( pMonitorInfoLeft );
hb_itemRelease( pMonitorInfoTop );
hb_itemRelease( pMonitorInfoBottom );
hb_itemRelease( pMonitorInfoRight );
hb_itemRelease( pWorkLeft );
hb_itemRelease( pWorkTop );
hb_itemRelease( pWorkBottom );
hb_itemRelease( pWorkRight );
hb_itemRelease( prctWork );
hb_itemRelease( prctMonitorInfo );
hb_itemRelease( prctMonitor );
hb_itemRelease( pIsPrimary );
hb_itemRelease( phdcMonitor );
hb_itemRelease( pHandleMonitor );
hb_itemRelease( pMonitorCount );
}
return hb_parl( -1 ); // .T. continue enumeration
}
HB_FUNC( ENUMDISPLAYMONITORS )
{
iMonitorCount = 0;
hb_retl( EnumDisplayMonitors( NULL, NULL, MonitorEnumProc, ( LPARAM ) hb_param( 1, HB_IT_BLOCK ) ) );
}
#pragma ENDDUMP
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Willi Quintana and 41 guests