Brian Heibert wrote: > How would I go about creating a sheet window that would say > Are you sure you want to quit URL Keeper? > and offer two buttons Yes & No The use of "yes" and "no" buttons characterises a popular but poorly contrived platform. The Mac way is to give descriptive names to the buttons (Quit and Cancel in the demo below). Robert P. '---------------------- '~'A ' Runtime : Rntm Appearance.Incl ' CPU : Carbon '~'B /* A sheet alert demo */ include "Tlbx CarbonEvents.incl" include "Tlbx Dialogs.incl" _mainWndNum = 1 end globals /* This is the 'call-back' from sheet closure. We get here after the button click but before the sheet has been closed. If the command is one of the relevant ones, we must close the sheet, then handle the user command. */ long if 0 "SheetDismissed" enterproc fn SheetDismissed( nextHandler as EventHandlerCallRef, theEvent as EventRef, userData as ptr ) '~'1 dim as OSStatus result dim as HICommand command dim as long parentWndNum result = _eventNotHandledErr call GetEventParameter( theEvent, _kEventParamDirectObject, ¬ _typeHICommand, #0, sizeof( HICommand ), #0, @command ) select command.commandID // we are interested in 2 commands case _kHICommandOK, _kHICommandCancel // let the standard handler close the sheet result = fn CallNextEventHandler( nextHandler, theEvent ) long if ( command.commandID == _kHICommandOK ) //... your code, if any, to handle 'Quit' would go here end xelse //... your code, if any, to handle 'Cancel' would go here parentWndNum = userData window parentWndNum // set port back to parent window end if end select exitproc = result end if // install handler on the sheet, supplying the parentWndNum as userData for later reference local fn InstallSheetDismissedHandler( sheetWndRef as WindowRef, parentWndNum as long ) '~'1 dim as EventTypeSpec eventType begin globals dim as ptr sDismissUPP // 'static' variable end globals long if ( sDismissUPP == 0 ) sDismissUPP = fn NewEventHandlerUPP( [proc "SheetDismissed" + _FBProcToProcPtrOffset] ) end if eventType.eventClass = _kEventClassCommand eventType.eventKind = _kEventProcessCommand call InstallEventHandler( fn GetWindowEventTarget( sheetWndRef ), ¬ sDismissUPP, 1, @eventType, #parentWndNum, #0 ) end fn local mode local fn DoSheetQuitAlert( parentWndNum as long ) '~'1 dim as WindowRef @ parentWndRef dim as DialogRef @ sheet dim as AlertStdCFStringAlertParamRec paramRec get window parentWndNum, parentWndRef call GetStandardAlertDefaultParams( paramRec, _kStdCFStringAlertVersionOne ) paramRec.defaultText = fn CFSTR( "Quit" ) paramRec.defaultButton = _kAlertStdAlertOKButton paramRec.cancelText = _kAlertDefaultCancelText paramRec.cancelButton = _kAlertStdAlertCancelButton call CreateStandardSheet( _kAlertNoteAlert, ¬ fn CFSTR( "Are you sure you want to quit?" ), 0, @paramRec, 0, @sheet ) // install handler on the sheet fn InstallSheetDismissedHandler( fn GetDialogWindow( sheet ), parentWndNum ) call ShowSheetWindow( fn GetDialogWindow( sheet ), parentWndRef ) end fn local mode local fn DoDialog '~'1 select dialog( 0 ) case _btnClick, _wndClose fn DoSheetQuitAlert( _mainWndNum ) end select end fn local mode local fn DoMenu '~'1 select menu( 0 ) case 1 // file menu select menu( 1 ) case 1, 2 // close, quit items fn DoSheetQuitAlert( _mainWndNum ) end select end select menu end fn local mode local fn BuildWindow( wndNum as long ) '~'1 dim as Rect r window wndNum, "My Window" print "Close window, click Quit button, or type Cmd-Q" SetRect( r, 180, 100, 280, 120 ) button 1, _activeBtn, "Quit", @r end fn // main menu 1, 0, 1, "File" menu 1, 1, 1, "Close/W" menu 1, 2, 1, "Quit/Q" on menu fn DoMenu on dialog fn DoDialog fn BuildWindow( _mainWndNum ) do HandleEvents until 0 '----------------------