[futurebasic] Re: [FB] IsProcessVisible demo [minor update]

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2004 : Group Archive : Group : All Groups

From: Brian Stevens <brilor@...>
Date: Sat, 25 Dec 2004 10:09:26 -0700
thanks to Bernie for pointing out the "visible" message was going 
nowhere when hide is selected from the menu instead of CMD-H. Here is 
the corrected version.



include "Tlbx CarbonEvents.Incl"
toolbox FN IsProcessVisible (ProcessSerialNumber *PSN) = boolean

dim as EventLoopTimerUPP   gTimerUPP
dim as EventLoopTimerRef   gTheTimerRef

local fn InstallCarbonTimer( initDelay as EventTimerInterval, 
repeatInterval as EventTimerInterval )
'~'1
dim as OSStatus  ignore
long if ( gTimerUPP == _nil )
gTimerUPP = fn NewEventLoopTimerUPP( [proc "CarbonTimerAction" + 
_FBprocToProcPtrOffset] )
end if
long if ( gTheTimerRef )
ignore = fn RemoveEventLoopTimer( gTheTimerRef ) // remove old
end if
end fn = fn InstallEventLoopTimer( fn GetMainEventLoop, initDelay, 
repeatInterval, gTimerUPP, #0, @gTheTimerRef )


long if 0
"CarbonTimerAction"
enterproc fn CarbonTimerAction( theTimer as EventLoopTimerRef, userData 
as long )
'~'1
dim as ProcessSerialNumber junkPSN
dim as OSErr               ignore

ignore = fn GetCurrentProcess( @junkPSN )
if fn IsProcessVisible (junkPSN) then window output 1 : print "visible" 
else beep
  // note: app can be in background but not hidden

exitproc
end if
'~Mainline
fn InstallCarbonTimer( 0, .5 )//says wait 0 seconds for the first timer
  //and then fire a timer every .5 seconds
poke long event - 8, 0xffffffff // essentially rules out null events 
for practical purposes

window 1, "Is Process Visible Demo", (0, 0)-(640, 480)

do
handleevents
until 0