home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / except1.zip / Except.C < prev    next >
C/C++ Source or Header  |  1994-09-26  |  4KB  |  130 lines

  1. #pragma    title("Exception Example  --  Version 1.0  --  ( Except.C)")
  2. #pragma    subtitle("   main() Module - Interface Definitions")
  3.  
  4. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  5. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  6.  
  7. #pragma    info(nopar)
  8.  
  9. #include <os2.h>
  10.  
  11. #include "appdefs.h"
  12. #include "ccls32.h"
  13. #include "except.h"
  14.  
  15. /* This    module contains    the main entry point to    the application    and    */
  16. /* also    performs that application interface setup with PM.        */
  17.  
  18. /* Filename:    Except.C                        */
  19.  
  20. /*  Version:   1.0                            */
  21. /*  Created:   1994-08-23                        */
  22. /*  Revised:   1994-08-23                        */
  23.  
  24. /* Routines:   INT main(INT argc, CHAR *argv[ ]);            */
  25.  
  26.  
  27. /* Copyright ╕ 1994, 1995  Prominare Inc.  All Rights Reserved.        */
  28.  
  29. /* --------------------------------------------------------------------    */
  30.  
  31. INT main(INT argc, CHAR    *argv[ ]);
  32. APIRET APIENTRY    ExceptionHandler(PEXCEPTIONREPORTRECORD    pxcptrepr,
  33.                  PEXCEPTIONREGISTRATIONRECORD pxcptregr,
  34.                  PCONTEXTRECORD    pcr, PVOID sysinfo);
  35.  
  36. static INTERNALADDRESSLIST aial[ ] = { { (PFNINTADD)main, "main" },
  37.                        { NULL, NULL } };
  38.  
  39. INTERNALADDRESS    intaddExcept =    { __FILE__, 0, aial };
  40.  
  41. PSZ pszExceptClassName = (PSZ)"Except";
  42.  
  43. INT main(INT argc, CHAR    *argv[ ])
  44.  
  45. {
  46. EXCEPTIONREGISTRATIONRECORD xcptregr;  /* Exception Record        */
  47. QMSG                qmsg;      /* PM Message Queue Holder    */
  48.  
  49.                /* Register the exception handler        */
  50.  
  51.  
  52. xcptregr.prev_structure      = NULL;
  53. xcptregr.ExceptionHandler = &ExceptionHandler;
  54. DosSetExceptionHandler(&xcptregr);
  55.  
  56.                /* Initialize the program for PM    and create the    */
  57.                /* message queue                    */
  58.  
  59. hmqExcept = WinCreateMsgQueue(hAB = WinInitialize(0UL),    0L);
  60.  
  61.                /* Register the window class            */
  62.  
  63. if ( !WinRegisterClass(hAB, pszExceptClassName,    (PFNWP)ExceptionExampleWndProc,
  64.                CS_SYNCPAINT | CS_SIZEREDRAW, 0UL) )
  65.    {
  66.    DosUnsetExceptionHandler(&xcptregr);
  67.    return(0);
  68.    }
  69.                /* Register the control class with OS/2        */
  70.                /* Presentation Manager and return registration    */
  71.                /* result                    */
  72.  
  73. if ( !WinRegisterClass(hAB, "PDS.3DLine", (PFNWP)Line3DWndProc,
  74.                CS_SYNCPAINT | CS_HITTEST | CS_PARENTCLIP | CS_SIZEREDRAW,
  75.                USER_CWINDOWWORDS) )
  76.    {
  77.    DosUnsetExceptionHandler(&xcptregr);
  78.    return(0);
  79.    }
  80.                /* Register the control class with OS/2        */
  81.                /* Presentation Manager and return registration    */
  82.                /* result                    */
  83.  
  84. if ( !WinRegisterClass(hAB, "PDS.3DText", (PFNWP)Text3DWndProc,
  85.             CS_SYNCPAINT | CS_HITTEST | CS_PARENTCLIP | CS_SIZEREDRAW,
  86.             USER_CWINDOWWORDS) )
  87.    {
  88.    DosUnsetExceptionHandler(&xcptregr);
  89.    return(0);
  90.    }
  91.                /* Create the main program window        */
  92.  
  93. if ( !(hwndExceptFrame = CreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  94.                      FCF_NOBYTEALIGN | FCF_TASKLIST    |
  95.                      FCF_TITLEBAR |    FCF_ICON | FCF_SYSMENU |
  96.                      FCF_MENU | FCF_MINMAX | FCF_SIZEBORDER,
  97.                      pszExceptClassName, (PSZ)"Exception Example", 0L,
  98.                      (HMODULE)NULL,    WIN_EXCEPTIONEXAMPLE, &hwndExcept, 8, 65, 322, 132)) )
  99.    {
  100.    DosUnsetExceptionHandler(&xcptregr);
  101.    return(0);
  102.    }
  103.                /* Perform application initialization        */
  104.  
  105. InitApp(hwndExceptFrame, hwndExcept, NULL);
  106.  
  107.                /* Get and dispatch the message to program    */
  108.                /* windows                    */
  109.  
  110. while (    WinGetMsg(hAB, &qmsg, (HWND)NULL, 0UL, 0UL) )
  111.    WinDispatchMsg(hAB, &qmsg);
  112.  
  113.                /* Have received    a WM_QUIT, start the program    */
  114.                /* shutdown by destroying the program windows    */
  115.                /* and destroying the message queue        */
  116.  
  117. WinDestroyWindow(hwndExceptFrame);
  118.  
  119. WinDestroyMsgQueue(hmqExcept);
  120.  
  121.                /* Notify PM that main program thread not needed    */
  122.                /* any longer                    */
  123. WinTerminate(hAB);
  124.  
  125. DosUnsetExceptionHandler(&xcptregr);
  126.  
  127.                /* Exit back to OS/2 cleanly            */
  128. return(0);
  129. }
  130.