[futurebasic] Re: [FB] Protecting an Appearance Button

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

From: Robert Purves <listrp@...>
Date: Mon, 16 Mar 2009 14:32:30 +1300
Rich Love wrote:

> In the old days of PG-Pro, there was a way to define a window that  
> would protect buttons from being overwritten by PRINT statements.
> That was a nice feature. It was called something like 'Drawing does  
> not overwrite controls'.
>
> Now that I am no longer using PG-PRO, is there a way to protect  
> buttons.
> In other words, if I create a button with the Appearance Button  
> statement, I want to protect if from being overwritten by a PRINT  
> statement.


'-----------
local mode
local fn ClipControl( c as ControlRef, protect as Boolean )
'~'1
dim as RgnHandle  ctrlRgn, clip
dim as CGrafPtr   oldPort

GetPort( oldPort )
SetPortWindowPort( fn GetControlOwner( c ) )
clip = fn NewRgn()
GetClip( clip )
ctrlRgn = fn NewRgn()
fn GetControlRegion( c, _kControlStructureMetaPart, ctrlRgn )
long if ( protect )
DiffRgn( clip, ctrlRgn, clip )
xelse
UnionRgn( clip, ctrlRgn, clip )
end if
DisposeRgn ( ctrlRgn )
SetClip( clip )
DisposeRgn( clip )
SetPort( oldPort )
end fn

dim as long j
dim as Rect r

window 1
SetRect( r, 180, 100, 280, 120 )
appearance button 1,,,,,"Button", @r, _kControlPushButtonProc
fn ClipControl( button&( 1 ), _zTrue )
for j = 1 to 20
print string$( 107, "a" )
next
fn ClipControl( button&( 1 ), _false )
do
HandleEvents
until gFBQuit
'-----------


Robert P.