Hi,
A second large monitor is connected to the laptop. At startup, my program opens on the laptop screen. How do I make the program open on the second large monitor at startup ?
Hi,
A second large monitor is connected to the laptop. At startup, my program opens on the laptop screen. How do I make the program open on the second large monitor at startup ?
To make your program open on the second large monitor at startup, you can use FiveWin's multi-monitor support functions. Here are the main approaches:
Add the
ACTIVATE WINDOW oWnd IN 2
// or
ACTIVATE DIALOG oDlg IN 2The
Get the second monitor object and pass it to the activate command:
ACTIVATE WINDOW oWnd IN FW_GetMonitor(2)The
Use
FW_SetMonitor(2) // Set second monitor as default
ACTIVATE WINDOW oWnd // Will open on second monitorTo center the window on the second monitor:
ACTIVATE WINDOW oWnd CENTERED IN 2The
You can check how many monitors are available:
nMonitors := FW_ActiveMonitors() // Returns number of active monitorsWiki pages you might want to explore:
File: whatsnew.txt (L538-540)
* Enhanced multi-monitor support:
ACTIVATE WINDOW/DIALOG [CENTERED] IN onMonitor
onMonitor can be number of the monitor or monitor object.File: source/function/getsysin.prg (L427-428)
function FW_ActiveMonitors()
return GetSysMetrics( SM_CMONITORS )File: source/function/getsysin.prg (L438-452)
function FW_SetMonitor(...)
static oMonitor
local oRet
oRet := oMonitor
if PCOUNT() > 0
oMonitor := HB_ExecFromArray( "FW_GETMONITOR", HB_AParams() )
if oMonitor:lPrimary
oMonitor := nil
endif
endif
return oRetFile: source/function/getsysin.prg (L456-486)
function FW_GetMonitor( nRow, nCol ) // POINT r,c [OR] nMonitor, [or] oWnd/hWnd No params: primary monitor
local aInfo, oMonitor, nMax
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() ) )
oMonitor := FW_GetAllMonitors()[ nMax ]
endif
endif
return oMonitorFile: source/function/getsysin.prg (L563-584)
CLASS TMonitor STATIC FROM TRect
DATA ClientRect
DATA lPrimary
METHOD New( aInfo ) CONSTRUCTOR
METHOD Move( oWnd )
METHOD Center( oWnd )
METHOD Row( r ) INLINE ( ::nTop + r )
METHOD Col( c ) INLINE ( ::nLeft + c )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( aInfo ) CLASS TMonitor
::Super:New( aInfo[ 1 ], aInfo[ 2 ], aInfo[ 3 ], aInfo[ 4 ] )
::ClientRect:= TRect():New( aInfo[ 5 ], aInfo[ 6 ], aInfo[ 7 ], aInfo[ 8 ] )
::lPrimary := aInfo[ 9 ]
return SelfFile: source/classes/window.prg (L1038-1170)
METHOD Activate( cShow, bLClicked, bRClicked, bMoved, bResized, bPainted,;
bKeyDown, bInit, bUp, bDown, bPgUp, bPgDown,;
bLeft, bRight, bPgLeft, bPgRight, bValid, bDropFiles,;
bLButtonUp, lCentered, oMonitor ) CLASS TWindow
local oVScroll, oHScroll
DEFAULT cShow := "NORMAL", lCentered := .F.
( bMoved, bResized, bKeyDown, bInit, bLButtonUp )
::nResult = nil
::lValidating = .f.
DEFAULT oMonitor := FW_SetMonitor()
if oMonitor != nil
if HB_ISNUMERIC( oMonitor )
oMonitor := FW_GetMonitor( oMonitor )
elseif !( HB_ISOBJECT( oMonitor ) .and. ( oMonitor:IsKindOf( "TMONITOR" ) .or. oMonitor:IsKindOf( "TWINDOW" ) ) )
oMonitor := nil
endif
endif
if bValid != nil
::bValid = bValid
endif
if bDropFiles != nil
::bDropFiles = bDropFiles
DragAcceptFiles( ::hWnd, .t. )
endif
if bPainted != nil
if ::IsKindof( "TMDIFRAME" ) // for "CLASS MyApp FROM TMdiFrame"
::oWndClient:bPainted = bPainted
else
::bPainted = bPainted
endif
endif
if bLClicked != nil
if ::IsKindof( "TMDIFRAME" )
::oWndClient:bLClicked = bLClicked
else
::bLClicked = bLClicked
endif
endif
if bRClicked != nil
if ::IsKindof( "TMDIFRAME" )
::oWndClient:bRClicked = bRClicked
else
::bRClicked = bRClicked
endif
endif
// For WS_VSCROLL and WS_HSCROLL styles
if ::IsKindof( "TMDIFRAME" )
oVScroll = ::oWndClient:oVScroll
oHScroll = ::oWndClient:oHScroll
else
oVScroll = ::oVScroll
oHScroll = ::oHScroll
endif
if oVScroll != nil // When using VSCROLL clause
if bUp != nil
oVScroll:bGoUp = bUp
else
if ::IsKindof( "TMDIFRAME" )
oVScroll:bGoUp = { || ScrollWindow( ::oWndClient:hWnd, 0, 20, 0, GetClientRect( ::oWndClient:hWnd ) ) }
endif
endif
if bDown != nil
oVScroll:bGoDown = bDown
else
if ::IsKindof( "TMDIFRAME" )
oVScroll:bGoDown = { || ScrollWindow( ::oWndClient:hWnd, 0, -20, 0, GetClientRect( ::oWndClient:hWnd ) ) }
endif
endif
if bPgUp != nil
oVScroll:bPageUp = bPgUp
endif
if bPgDown != nil
oVScroll:bPageDown = bPgDown
endif
endif
if oHScroll != nil // When using HSCROLL clause
if bLeft != nil
oHScroll:bGoUp = bLeft
else
if ::IsKindof( "TMDIFRAME" )
oHScroll:bGoUp = { || ScrollWindow( ::oWndClient:hWnd, 20, 0, 0, GetClientRect( ::oWndClient:hWnd ) ), ReleaseCapture() }
endif
endif
if bRight != nil
oHScroll:bGoDown = bRight
else
if ::IsKindof( "TMDIFRAME" )
oHScroll:bGoDown = { || ScrollWindow( ::oWndClient:hWnd, -20, 0, 0, GetClientRect( ::oWndClient:hWnd ) ), ReleaseCapture() }
endif
endif
if bPgLeft != nil
oHScroll:bPageUp = bPgLeft
endif
if bPgRight != nil
oHScroll:bPageDown = bPgRight
endif
endif
::AEvalWhen()
if ! lWRunning()
SetWndApp( ::hWnd )
endif
if ::bInit != nil
Eval( ::bInit, Self )
endif
::Resize( 0, ::nWidth, ::nHeight )
if lCentered
if oMonitor == nil
::Center()
else
WndCenterEx( ::hWnd, oMonitor )
endif
elseif oMonitor != nil .and. oMonitor:IsKindOf( "TMONITOR" )
oMonitor:Move( Self )
endifThank you, Antonio!