[futurebasic] Re: [FB] CE Installer

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2006 : Group Archive : Group : All Groups

From: Bernie <fb.list@...>
Date: Sun, 30 Apr 2006 09:46:56 +0100
Max asked:

> If you have more than one window or Control, etc. do you have to  
> install the events for each one individually or does one cover all?


I don't know if this is recommended practice but I suppose you could  
install a control hit handler on the application, so 'one call does  
it all'.

'----------
include "Tlbx CarbonEvents.incl"

local fn InstallApplicationControlHitHandler
'~'1
dim as EventTypeSpec  theEvent
dim as OSStatus       ignore

begin globals
dim as pointer  sApplicationControlHitHandlerUPP
end globals
long if ( sApplicationControlHitHandlerUPP == 0 )
sApplicationControlHitHandlerUPP = fn NewEventHandlerUPP( ¬
[proc "MyControlHitHandler" + _FBprocToProcPtrOffset] )
end if

theEvent.eventClass = _kEventClassControl
theEvent.eventKind  = _kEventControlHit
ignore = fn InstallEventHandler( fn GetApplicationEventTarget(), ¬
sApplicationControlHitHandlerUPP, 1, @theEvent, #0, #0 )
end fn


long if 0
"MyControlHitHandler"
enterproc fn MyControlHitHandler( nextHandler as EventHandlerCallRef, ¬
theEvent as EventRef, userData as pointer ) = OSStatus
'~'1
dim as ControlRef  @ c
dim as long          wndNum, btnNum
dim as OSStatus      result

result = _eventNotHandledErr
select fn GetEventClass( theEvent )
case _kEventClassControl
select fn GetEventKind( theEvent )
case _kEventControlHit
call GetEventParameter( theEvent, _kEventParamDirectObject, ¬
_typeControlRef, #0, sizeof( ControlRef ), #0, @c )
wndNum = usr WPtr2WNum( fn GetControlOwner( c ) )// get FB wnd number
btnNum = usr Handle2Btn( c )// get FB btn number

beep

end select
end select
exitproc = result
end If


local fn BuildWindow( wndNum as long )
'~'1
dim as Rect  r

SetRect( r, 0, 44, 250, 214 )
appearance window -wndNum, "Untitled" + str$(wndNum), @r, ¬
_kDocumentWindowClass, _kWindowStandardHandlerAttribute

SetRect( r, 90, 75, 160, 95 )
appearance button 1, _activeBtn,,,, "Button", @r,  
_kControlPushButtonProc

window wndNum
end fn

def NewWindowPositionMethod( _kWindowCascadeOnMainScreen )

fn BuildWindow( 1 )
fn BuildWindow( 2 )
fn BuildWindow( 3 )
fn BuildWindow( 4 )

fn InstallApplicationControlHitHandler

RunApplicationEventLoop()
'----------