xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

SetCancel()

Determines if Alt+C and Ctrl+Break terminate an application

Syntax

SetCancel( [<lOnOff>] ) --> lOldSetting

Arguments

<lOnOff>
This is a logical value. If .T. (true) is passed, the keys Alt+C and Ctrl+Break terminate an application unconditionally. .F. (false) disables automatic program termination when a user presses these keys.

Return

The function returns the setting which is active before SetCancel() is called.

Description

SetCancel() is used to disable the automatic program termination routine which can be activated by pressing the keys Alt+C or Ctrl+Break. The setting is .T. (true) by default. When a user presses either key combination, an xHarbour application is terminated unconditionally.

If automatic program termination is not desired, SetCancel() should be set to .F. (false) and a program termination routine should be implemented.

Info

See also:SET ESCAPE, SET KEY, Set(), SetKey()
Category: Environment functions
Source:rtl\set.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates howto override the default program termination
// for Alt+C or Ctrl+Break with a user defined one.

   #include "Inkey.ch"


   PROCEDURE Main

      WAIT "Alt+C terminates unconditionally"

      SetCancel( .F. )
      SetKey( K_ALT_C, {|| MyExitProc() } )

      WAIT "Alt+C calls user defined exit routine"

      ? "Normal program termination"
   RETURN


   PROCEDURE MyExitProc
      LOCAL n := Alert( "Exit program?", { "Yes", "No" } )

      IF n == 1
         ? "User terminated program"
         QUIT
      ENDIF
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe