Tech Tip: Obtaining monitor screen number of a focused form in SDI mode
PRODUCT: 4D | VERSION: 16R4 | PLATFORM: Win
Published On: September 28, 2017
In v16R4, a database in Windows can be in SDI (Single Document Interface) mode which means that the forms do not have to be working under one desktop window. Forms can be moved around between different monitor screens. The following utility will report the current screen number used from the Count screens command:
// ---------------------------------------------------------- // Method: GET_FOCUSED_SCR_NUM // Description: Method will return the current focus form's // screen number that was found on Count screens for // databases that are in SDI mode. // // Output: // $0 (LONGINT) - Focused form screen number // ---------------------------------------------------------- C_LONGINT($i;$numScreens) C_LONGINT($leftWR;$topWR;$rightWR;$bottomWR) C_LONGINT($leftSC;$topSC;$rightSC;$bottomSC) C_LONGINT($0) $numScreens:=Count screens GET WINDOW RECT($leftWR;$topWR;$rightWR;$bottomWR) For ($i;1;$numScreens) SCREEN COORDINATES($leftSC;$topSC;$rightSC;$bottomSC;$i) If (($leftWR>=$leftSC) & ($topWR>=$topSC) & ($rightWR<=$rightSC) & ($bottomWR<=$bottomSC)) $0:=$i End if End for |
Here is an example of a form that is on Screen #1:
C_LONGINT($scrNum) $scrNum:=GET_FOCUSED_SCR_NUM // returns: 1 |
Here is an example of a form that is on Screen #2:
C_LONGINT($scrNum) $scrNum:=GET_FOCUSED_SCR_NUM // returns: 2 |
See Also: