home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / os2 / eaedit / easinit.c < prev   
C/C++ Source or Header  |  1999-05-11  |  6KB  |  110 lines

  1. /*static char *SCCSID = "@(#)easinit.c    6.5 92/02/18";*/
  2. /*==============================================================*\
  3.  *  EASINIT.C - routines for initialization and exit processing *
  4.  *      (C) Copyright IBM Corporation 1992.                     *
  5.  *--------------------------------------------------------------*
  6.  *                                                              *
  7.  *  This module contains the code for application initialization*
  8.  *  as well as the code for exit list processing                *
  9.  *                                                              *
  10.  *--------------------------------------------------------------*
  11.  *                                                              *
  12.  *  This source file contains the following functions:          *
  13.  *                                                              *
  14.  *      Init() - initialization routines                        *
  15.  *      ExitProc(usTermCode) - exit list processing procedure   *
  16.  *                                                              *
  17. \*==============================================================*/
  18.  
  19. /*--------------------------------------------------------------*\
  20.  *  Include files, macros, defined constants, and externs       *
  21. \*--------------------------------------------------------------*/
  22. #include "eas.h"
  23.  
  24. /****************************************************************\
  25.  *  Initialization routine                                      *
  26.  *--------------------------------------------------------------*
  27.  *                                                              *
  28.  *  Name:    Init()                                             *
  29.  *                                                              *
  30.  *  Purpose: Performs initialization functions required before  *
  31.  *           the main window can be created.                    *
  32.  *                                                              *
  33.  *  Usage:   Called once before the main window is created.     *
  34.  *                                                              *
  35.  *  Method:  - installs the routine ExitProc into the           *
  36.  *              DosExitList chain                               *
  37.  *           - registers all window classes                     *
  38.  *           - performs any command line processing             *
  39.  *                                                              *
  40.  *  Returns: TRUE - initialization is successful                *
  41.  *           FALSE - initialization failed                      *
  42.  *                                                              *
  43. \****************************************************************/
  44. BOOL Init(VOID)
  45. {
  46.     /* Add ExitProc to the exit list to handle the exit processing */
  47.     if(DosExitList(EXLST_ADD, ExitProc))
  48.     {
  49.         return FALSE;
  50.     }
  51.                        /* load application name from resource file */
  52.     if(!WinLoadString(hab, (HMODULE)0, IDS_APPNAME, MAXAPPNAMELEN, szAppName))
  53.         return FALSE;
  54.     if(!WinLoadString(hab, 0, IDS_UNTITLED, MESSAGELEN, szUntitled))
  55.         return FALSE;
  56.                           /* register the main client window class */
  57.     if(WinRegisterClass(hab,
  58.                         (PSZ)szAppName,
  59.                         (PFNWP)MainWndProc,
  60.                         CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPCHILDREN,
  61.                         0) == 0)
  62.         return FALSE;
  63.  
  64.     /* Turn off hard-error popup after GP-FAULT. No return codes
  65.        checked as it is cosmetic and if it doesn't work the only side
  66.        effect will be to have the default hard-error popup show up. */
  67.  
  68.     return TRUE;
  69. }                                                         /* Init() */
  70.  
  71. /****************************************************************\
  72.  *  Exit list processing procedure                              *
  73.  *--------------------------------------------------------------*
  74.  *                                                              *
  75.  *  Name:    ExitProc(usTermCode)                               *
  76.  *                                                              *
  77.  *  Purpose: Cleans up certain resources when the application   *
  78.  *           terminates                                         *
  79.  *                                                              *
  80.  *  Usage:   Routine is called by DosExitList when the          *
  81.  *           application exits                                  *
  82.  *                                                              *
  83.  *  Method:  global resources, such as the main window and      *
  84.  *           message queue, are destroyed and any system        *
  85.  *           resources used are freed                           *
  86.  *                                                              *
  87.  *  Returns: Returns EXLST_EXIT to the DosExitList handler      *
  88.  *                                                              *
  89. \****************************************************************/
  90. VOID APIENTRY ExitProc(ULONG usTermCode)
  91.                                   /* code for the reason for termination */
  92. {
  93.    WinDestroyWindow(hwndMainFrame);
  94.    /*--------------------------------------------------*\
  95.     *      Any other system resources used             *
  96.     *      (e.g. memory or files) should be freed here *
  97.    \*--------------------------------------------------*/
  98.    WinDestroyMsgQueue(hmq);
  99.  
  100.    WinTerminate(hab);
  101.  
  102.    DosExitList(EXLST_EXIT, (PFNEXITLIST)0L);    /* termination complete */
  103.  
  104.    /* This routine currently doesn't use the usTermCode parameter so *\
  105.     *  it is referenced here to prevent an 'Unreferenced Parameter'  *
  106.    \*  warning at compile time                                       */
  107.  
  108.    return;
  109. }                                                          /* ExitProc() */
  110.