Reputation: 53
Is it possible to define on which screen a window appears? I tried to find a solution, but all the time get only info about how to put somthing on screen or how to monitor a database.
Upvotes: 2
Views: 318
Reputation: 7192
Assuming this is classic ABL GUI.
The Window's position on the screen is determined by the X and Y attribute of the window. That is in pixel relative to the top/left corner of the "primary" screen.
You need to go to X < 0 (negative) if your default screen is the right one and you want to address the left monitor.
You can use the .NET System.Windows.Forms.Screens:AllScreens array to get details about the available monitors and their size and relative desktop positions:
DEFINE VARIABLE oScreens AS System.Windows.Forms.Screen NO-UNDO EXTENT .
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
/* Gets an array of all the screens connected to the system. */
ASSIGN oScreens = System.Windows.Forms.Screen:AllScreens
iCount = EXTENT(oScreens) .
DO i = 1 TO iCount :
MESSAGE "screen" i SKIP
"Width" oScreens[i]:Bounds:WIDTH SKIP
"Height" oScreens[i]:Bounds:HEIGHT SKIP
"X" oScreens[i]:Bounds:X SKIP
"Y" oScreens[i]:Bounds:Y SKIP
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
END.
DEFAULT-WINDOW:VISIBLE = TRUE .
DEFAULT-WINDOW:X = -1000 .
MESSAGE DEFAULT-WINDOW:X DEFAULT-WINDOW:Y .
For instance my left screen (center is primary) is 2560x1440 and starts with X = -2560.
So to have a window on it's top left corner, I set X to -2560 and Y to 0.
Upvotes: 9