[futurebasic] RE: [FB] invisible window contents

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2001 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 15 Mar 2001 08:35:12 +1300
>OK people, I got this thing narrowed down to just one issue which is
>call getgworld(port,portDevice)
>call setgworld(port,portDevice)

>I replaced ALL getgworlds w/getport and replaced all setgworlds w/setport
>EXCEPT in one function that clears my two gworlds.  The one function does

>local fn clearWorlds
>dim as ptr crntPort
>call getgworld(crntPort,fn getgworlddevice(crntPort))
>call setgworld(gFirstGworld,fn getgworlddevice(gFirstGworld))
>call eraserect(gFirstGworld+ _portrect)
>call setgworld(gSecondGworld,fn getgworlddevice(gSecondGworld))
>call eraserect(gSecondGworld+ _portrect)
>call setgworld(crntPort,fn getgworlddevice(crntPort))
>end fn

Your GetGWorld and your last SetGWorld look like a sure recipe for
mis-setting the graphics device. GetGWorld is defined like this:

toolbox GetGWorld(@long,@long) `0x203C,0x0008,0x0005,0xAB1D

The parameters actually passed to the Toolbox GetGWorld are pointers to
4-byte locations where returned values can be safely stored.
GetGWorldDevice has no role here.

Try it like this:

dim gFirstGWorld as ptr to GrafPort // really a CGrafPort
dim gSecondGWorld as ptr to GrafPort // really a CGrafPort
end globals

local fn clearWorlds
dim as ptr     @ crntGW
dim as handle  @ crntDevice
call GetGWorld( crntGW, crntDevice ) // remember port/device
call SetGWorld( gFirstGWorld, 0 )
call EraseRect( gFirstGWorld.portRect )
call SetGWorld( gSecondGWorld, 0 )
call EraseRect( gSecondGWorld.portRect )
call SetGWorld( crntGW, crntDevice ) // restore port/device
end fn

I also changed the way to get the portRect. The way you wrote it:
>call eraserect(gFirstGworld+ _portrect)
is not legal syntax.

A correct way of remembering and restoring the port was recommended rather
recently in this thread:

>dim @ windowGW as ptr, screenDevice as handle
>dim myGW as ptr
>dim err  as OSErr
>window 1
>GetGWorld( windowGW, screenDevice ) // remember port/device
>err = fn NewGWorld( myGW, ... )
>SetGWorld( myGW, 0 )
>//... do stuff
>SetGWorld( windowGW, screenDevice ) // restore port/device
>// now OK to close window 1

Robert P.