[futurebasic] Re: Working with multiple monitors

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Thu, 12 Jun 2003 11:16:01 -0400
Robert Covington asked:

>I  have questions regarding 3 things with multiple monitors.
>
>1. How to count the number of monitors... Get DeviceList seems the
>trick, and there is a PG thing for that.
>
>2.  Get the screen resolution of each ...System(_scrnWidth) and such
>seem questionable in the case of the mult-setup, and would end up just
>giving the main monitor I would guess?
>
>Lastly,
>
>3. Open a window and have it appear in each monitor (only 1 window,
>moving over) given a keypress...such as F1 to advance, and F2 to go
>back among the list.


As a follow up to Robert's question, Bill Michael suggested looking
at the Function Junction examples.

I had a little time this morning and converted a Function Junction II
demo to FB^3. This should answer questions 1 and 2 above. If I have
time I will work on the conversion that covers question 3.

This code works in 68K through OS X Carbon in Standard BASIC and
Appearance Compliant.

Ken Shmidheiser

p.s. Watch for e-mail line breaks and lost constant underscores on
the Associate server.


/*

     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

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 )
fn  Results( i, depth )
next i

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

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