Jump to content

WinTerminate: Difference between revisions

From EDM2
Ak120 (talk | contribs)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Syntax ===
'''WinTerminate''' clean up after resouce allocated by [[WinInitialize]] function.


  rc = WinTerminate( ''hab'' )
==Syntax==
  WinTerminate( ''hab'' )


=== Parameters ===
;''hab'' ([[HAB]]) - input:Handle of Anchor Block returned from WinInititalize.


=== Parameters ===
  HAB ''hab'' Handle of Anchor Block returned from WinInititalize.
=== Returns ===
=== Returns ===
;''rc'' ([[BOOL]]) - returns : Termination indicator.
<pre>
:;TRUE
BOOL  rc
::Application usage of Presentation Manager successfully terminated
:;FALSE
:Application usage of Presentation Manager not successfully terminated, or WinInitialize has not been issued on this thread.


  TRUE  on success
==Remarks==
  FALSE  on error
It is good practice to issue this function before terminating an application thread. Before issuing this function, the application must destroy all windows and message queues that have been created by the thread, and return any cached presentation spaces to the cache. If it does not do so, the results, and the return value from this and subsequent calls are indeterminate.


</pre>
=== Include Info ===
=== Include Info ===
  #define INCL_WIN
  #define INCL_WIN
or
or
Line 24: Line 23:
or
or
  #define INCL_WINDOWMGR
  #define INCL_WINDOWMGR
  #include &lt;os2.h&gt;
  #include <os2.h>


=== Sample Code ===
Definition:
<pre>
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>


=== Usage Explanation ===
HAB    hab;  /*  Anchor-block handle. */
BOOL    rc;  /*  Termination indicator. */


WinTerminate clean up after resouce allocated by WinInitialize function.
rc = WinTerminate(hab);
 
</pre>
 
Sample:
=== Relevant Structures ===
=== Gotchas ===
=== Sample Code ===
<pre>  
<pre>  
int main()
int main()
Line 42: Line 42:
   HAB hab;
   HAB hab;
    
    
   hab = WinInitialize( 0 );
   hab = WinInitialize( 0 );  
 
   ...
   ...
 
   WinTerminate( hab );
   WinTerminate( hab );
   return 0;
   return 0;
}
}
</pre>  
</pre>
=== See Also ===
 
[[OS2 API:PMI:WinInitialize|WinInitialize]]
This example calls WinTerminate in a typical termination sequence.
<pre>
#define INCL_WINWINDOWMGR
#include <OS2.H>
HAB hab;
HWND hwndFrame;
QMSG qmsg;
HMQ hmq;
 
      while( WinGetMsg( hab, &qmsg, NULL, 0, 0 ) )
        WinDispatchMsg( hab,              /* PM anchor block handle        */
                        &qmsg );          /* pointer to message            */
 
 
  /* Destroy the standard windows if they were created.                      */
 
  if ( hwndFrame != NULL )
      WinDestroyWindow( hwndFrame );        /* frame window handle            */
 
  /* Destroy the message queue and release the anchor block.                */
 
  if ( hmq != NULL )
      WinDestroyMsgQueue( hmq );
 
  if ( hab != NULL )
      WinTerminate( hab );
</pre>
=== Related Functions ===
*[[WinInitialize]]
*[[WinCancelShutdown]]
*[[WinCreateMsgQueue]]




[[Category:The OS/2 API Project]]
[[Category:Win]]

Latest revision as of 19:00, 10 April 2025

WinTerminate clean up after resouce allocated by WinInitialize function.

Syntax

WinTerminate( hab )

Parameters

hab (HAB) - input
Handle of Anchor Block returned from WinInititalize.

Returns

rc (BOOL) - returns
Termination indicator.
TRUE
Application usage of Presentation Manager successfully terminated
FALSE
Application usage of Presentation Manager not successfully terminated, or WinInitialize has not been issued on this thread.

Remarks

It is good practice to issue this function before terminating an application thread. Before issuing this function, the application must destroy all windows and message queues that have been created by the thread, and return any cached presentation spaces to the cache. If it does not do so, the results, and the return value from this and subsequent calls are indeterminate.

Include Info

#define INCL_WIN

or

#include INCL_PM

or

#define INCL_WINDOWMGR
#include <os2.h>

Sample Code

Definition:

#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>

HAB     hab;  /*  Anchor-block handle. */
BOOL    rc;   /*  Termination indicator. */

rc = WinTerminate(hab);

Sample:

 
int main()
{
   HAB hab;
   
   hab = WinInitialize( 0 );   
   ...
   WinTerminate( hab );
   return 0;
}

This example calls WinTerminate in a typical termination sequence.

#define INCL_WINWINDOWMGR
#include <OS2.H>
HAB hab;
HWND hwndFrame;
QMSG qmsg;
HMQ hmq;

      while( WinGetMsg( hab, &qmsg, NULL, 0, 0 ) )
         WinDispatchMsg( hab,               /* PM anchor block handle         */
                         &qmsg );           /* pointer to message             */


   /* Destroy the standard windows if they were created.                      */

   if ( hwndFrame != NULL )
      WinDestroyWindow( hwndFrame );        /* frame window handle            */

   /* Destroy the message queue and release the anchor block.                 */

   if ( hmq != NULL )
      WinDestroyMsgQueue( hmq );

   if ( hab != NULL )
      WinTerminate( hab );

Related Functions