[futurebasic] Re: [FB] Re: Working with multiple monitors

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2003 : Group Archive : Group : All Groups

From: tedd <tedd@...>
Date: Thu, 12 Jun 2003 17:44:42 -0400
Robert:

>Can any of you with multi monitor setups (Tedd! :) ) make a window,
>then offset it by the current width of the main monitor and see if
>it shows up on the other?

Yes, the below program does the trick. The last window is on the
second monitor.

Also, the monitor with top-left being 0,0 is not always the number 1
monitor (the one with the menu bar). I don't know how to find out
which monitor is the one that has the menu bar.

tedd

---

/*

     Code based on FN getMonitor.BAS by Ross W. Lambert
     Copyright © 1995, Ariel Publishing, Inc.

     FB^3 conversion
     By Ken Shmidheiser
     Somerset, KY
     6-12-03

     Runs in 68K through OS X Carbon in Standard BASIC
     and Appearance Compliant. (68K returns color depth
     as a negative number)

*/

begin globals
dim as rect   gMonRect
end globals

/*
    FN CountMonitors scans the list of graphics devices and returns
    the count. These are all display devices of one type or another.
*/
local mode
local fn CountMonitors
dim as long   count
dim as handle devH

count = 0
devH = FN GetDeviceList

do
long if devH
count++
end if
devH = fn GetNextDevice( devH )
until devH = 0

end fn = count

/*
    Given a display number (1 to n), FN GetMonitor returns the QuickDraw
    rectangle for the device as well as its  current color depth.
  */
local mode
local fn GetMonitor( monitor as long, @rPtr as long )
dim as long    count, colorDepth
dim as handle  devH
dim as pointer pixMapPtr

      count = 1// Look at monitor 1 to start
       devH = FN GetDeviceList// Get first graphics device handle
colorDepth = -1// Flag error till proven otherwise

do
long if devH// Okay for nil
long if count = monitor// Is this the one we want?
BlockMove [devH] + _gdRect, rPtr, 8// Return graphics device rectangle
pixMapPtr = [[[devH] + _gdpMap]]// Find pixmap
colorDepth = 2^({ pixMapPtr + _pmPixelSize} )// Look up pixel depth
count = -1// Found flag
end if// { end if this monitor is target }
count++
end if// { end if valid gdevice }
devH = fn GetNextDevice( devH )// Look at next device
until devH = _nil OR count = -1// Loop until no more or we found ours

end fn = colorDepth// Returns color depth


local fn Results( monitor as long, depth as long )

print monitor, gMonRect.top, gMonRect.left,¬
       gMonRect.bottom, gMonRect.right, depth

end fn

window 1, "FN GetMonitor Demo"
text _Monaco, 9

dim as long i, monitorCount, depth
dim as int maxX, maxY
print
monitorCount = FN CountMonitors
long if monitorCount = 1
print "There is one monitor."
xelse
print "There are"; monitorCount" monitors."
end if

print
def tab 10
print "Monitor", "Top", "Left", "Bottom", "Right", "Colors"
print "--------------------------------------------------------"

for i = 1 to monitorCount
depth = fn GetMonitor( i, gMonRect )
long if i = 1
maxX = gMonRect.right%
maxY = gMonRect.bottom%/2
end if
fn  Results( i, depth )
next i
print
print maxX, maxY

print chr$(13); "Press any key or mouse to end..."

window 2, "Demo", (maxX,maxY)-(maxX + 200,maxY + 200)

do
handleevents
until len( inkey$ ) > 0 or fn Button
end