[futurebasic] Re: [FB] Background application

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

From: Robert Purves <robert.purves@...>
Date: Sun, 25 May 2003 15:53:26 +1200
On Wednesday, May 21, 2003, David Cox wrote:

> Has anybody been able to compile a carbon app that runs in the 
> background like a daemon (I can hide it, but not remove it from the 
> dock)?

1. Use ResEdit to open the compiled app, and in the size resource, set 
the Only Background radio buttons to indicate 1 (ON).

2. You may also need to call ShowHideProcess, as in the demo below. A 
quick test in 10.2.4 suggests that this is *not* necessary, but it is 
the official recommendation, and I seem to remember that in some 
earlier OS X version it was required.

'-----------------
'~'A
'                           CPU : Carbon
'~'B

toolbox fn ShowHideProcess( ProcessSerialNumber * psn, Boolean visible 
) = OSErr

dim as ProcessSerialNumber curPSN
dim as long   t
dim as OSErr  err
curPSN.highLongOfPSN = 0
curPSN.lowLongOfPSN  = _kCurrentProcess
// hide myself
err = fn ShowHideProcess( curPSN, _false )
t = fn TickCount
beep
// hang around (invisibly) for 5 s
do
HandleEvents
until ( fn TickCount > t + 5*60 )
beep
end
'-----------------


Robert P.