Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>c4w_autoclose()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
C4W_AutoClose()
Enable/disable automatic closing of windows
------------------------------------------------------------------------------

Syntax
C4W_AutoClose( <lEnable> )   -->   lOldState

Arguments
<lEnable> is a logical value, which should be TRUE (.T.) to
enable auto-closing of windows and FALSE (.F.) to disable it.

Returns
A logical TRUE (.T.) is returned if auto-closing was
previously enabled.  Otherwise, FALSE (.F.) is returned.

Description
This function can be used to enable or disable automatic
closing of windows.

When enabled, choosing Close from the system menu of a window,
or typing Alt-F4, or sending a WM_CLOSE message to a window
will cause the window to be destroyed.

When disabled, the window will receive a WM_CLOSE message,
which is passed through the event queue as an EVENT_CLOSE
event.  Commonly, an application would examine the window
handle to see if it is the handle for the application's main
window (or a window with unsaved information of some sort).
If it is not, the application would probably just use
DestroyWindow().  Otherwise, you'd probably want to query the
user, typically using MessageBox().

By default, automatic closing is enabled.

Example
// at the start of your app:
c4w_AutoClose( .F. )

// . . .

// in your event handler:
do case
case nEvent == EVENT_CLOSE
     hWnd = _LasthWnd()
     if  hWnd == hMainWnd
          if  MessageBox( hMainWnd, "Really Exit?", "MyApp",          ;
                          MB_ICONQUESTION + MB_OKCANCEL ) == IDOK
               // . . .
               //  do any clean-up needed
               // . . .
               DestroyWindow( hMainWnd )
               quit
          endif
     else
          DestroyWindow( hWnd )
     endif
// . . .
endcase


See Also: DestroyWindow() MessageBox()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson