Changeset 1341


Ignore:
Timestamp:
Dec 14, 2008, 11:18:26 PM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: add thread 1 exception handler support to applets

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/av2.c

    r1238 r1341  
    1212  23 Sep 07 SHL Get rid of statics
    1313  17 Sep 08 JBS Convert to use of wrapped DosFind... (i.e. xDosFind...)
     14  14 Dec 08 SHL Add exception handler support
    1415
    1516***********************************************************************/
    1617
    17 #include <stdlib.h>
     18#include <stdlib.h>                     // getenv
    1819#include <string.h>
    1920
     
    2122#define INCL_WIN
    2223#define INCL_LONGLONG
     24#define INCL_DOSEXCEPTIONS              // XCTP_...
     25#define INCL_DOSERRORS                  // NO_ERROR
    2326
    2427#include "dll\fm3dll.h"
    25 #include "dll\mainwnd.h"                // Data declaration(s)
    26 #include "dll\init.h"                   // Data declaration(s)
    27 #include "dll\notebook.h"               // Data declaration(s)
     28#include "dll\mainwnd.h"                // hwndBubble
     29#include "dll\notebook.h"               // appname hwndHelp
    2830#include "dll\arccnrs.h"
    2931#include "dll\fm3str.h"
     
    3537#include "dll\dirs.h"                   // switch_to
    3638#include "dll\viewer.h"                 // StartMLEEditor
    37 #include "dll\getnames.h"                       // insert_filename
     39#include "dll\getnames.h"               // insert_filename
    3840#include "dll\copyf.h"                  // unlinkf
    3941#include "dll\init.h"                   // InitFM3DLL
    4042#include "dll\valid.h"                  // IsFile
    4143#include "dll\wrappers.h"               // xDosFind...
     44#include "dll\errutil.h"                // Error reporting
     45#include "dll\excputil.h"               // Exception handlers
     46
     47static PSZ pszSrcFile = __FILE__;
    4248
    4349HMTX av2Sem;
     
    97103  HMQ hmq;
    98104  QMSG qmsg;
    99   HWND hwndFrame = (HWND) 0;
    100   static CHAR fullname[CCHMAXPATH];     // 23 Sep 07 SHL fixme to not be static
    101   CHAR *thisarg = NULL;
    102   INT x;
    103 
    104   *fullname = 0;
     105  HWND hwndFrame = 0;
     106  CHAR fullname[CCHMAXPATH] = { 0 };    // 14 Dec 08 SHL was static
     107  PSZ thisarg = NULL;
     108  UINT x;
     109  APIRET regRet;
     110  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
     111
    105112  strcpy(appname, "AV/2");
    106113  fAmAV2 = TRUE;
    107114  DosError(FERR_DISABLEHARDERR);
     115
     116  regRec.ExceptionHandler = HandleException;
     117  regRet = DosSetExceptionHandler(&regRec);
     118  if (regRet != NO_ERROR) {
     119    DbgMsg(pszSrcFile, __LINE__,
     120           "DosSetExceptionHandler failed with error %u", regRet);
     121  }
     122
    108123  for (x = 1; x < argc; x++) {
    109124    if (!strchr("/;,`\'", *argv[x]) &&
     
    116131    }
    117132  }
     133
    118134  DosExitList(EXLST_ADD, deinit);
     135
    119136  if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem))
    120137    DosCreateMutexSem("\\SEM32\\AV2", &av2Sem, DC_SEM_SHARED, FALSE);
     138
    121139  if (thisarg) {
    122140    if (DosQueryPathInfo(thisarg,
     
    149167    }
    150168  }
     169
    151170  hab = WinInitialize(0);
    152171  if (hab) {
  • trunk/databar.c

    r1203 r1341  
    99  Copyright (c) 2005, 2008 Steven H. Levine
    1010
    11   Oct 15 21:42:56 2002 967 ______ databar.c
    12 
    1311  15 Oct 02 SHL Baseline
    1412  07 Dec 05 SHL Avoid warnings
     13  14 Dec 08 SHL Add exception handler support
     14  14 Dec 08 SHL Drop NEVER used code
    1515
    1616***********************************************************************/
     
    1818#include <string.h>
    1919
    20 #define INCL_DOS
    2120#define INCL_WIN
    2221#define INCL_LONGLONG
     22#define INCL_DOSEXCEPTIONS              // XCTP_...
     23#define INCL_DOSERRORS                  // NO_ERROR
    2324
    2425#include "dll\fm3dll.h"
    25 #include "dll\notebook.h"                       // Data declaration(s)
    26 #include "dll\notebook.h"               // Data declaration(s)
     26#include "dll\notebook.h"               // appname
    2727#include "dll\datamin.h"
    2828#include "dll\fm3dlg.h"
    2929#include "dll\init.h"                   // InitFM3DLL
     30#include "dll\errutil.h"                // Error reporting
     31#include "dll\excputil.h"               // Exception handlers
    3032
    31 #ifdef NEVER                            // 05 Jan 08 SHL fixme to be gone?
    32 
    33 VOID APIENTRY deinit(ULONG why)
    34 {
    35   if (fmprof)
    36     PrfCloseProfile(fmprof);
    37   fmprof = (HINI) 0;
    38 
    39   flushall();
    40 
    41   DosExitList(EXLST_REMOVE, deinit);
    42 }
    43 
    44 #endif
     33static PSZ pszSrcFile = __FILE__;
    4534
    4635int main(int argc, char *argv[])
     
    4938  HMQ hmq;
    5039  QMSG qmsg;
     40  APIRET regRet;
     41  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    5142
    5243  strcpy(appname, "DATABAR");
    5344
    54 # ifdef NEVER
    55   DosExitList(EXLST_ADD, deinit);
    56 # endif
     45  regRec.ExceptionHandler = HandleException;
     46  regRet = DosSetExceptionHandler(&regRec);
     47  if (regRet != NO_ERROR) {
     48    DbgMsg(pszSrcFile, __LINE__,
     49           "DosSetExceptionHandler failed with error %u", regRet);
     50  }
    5751
    5852  hab = WinInitialize(0);
  • trunk/databar.def

    r1280 r1341  
    77option description '@#SLAInc:3.15.0#@##1## 11/18/2008 03:15:00      GKYBuild::EN:US:0:U:@@FM/2 Databar MiniApp Copyright (c) 1993, 1998 M. Kimes Copyright (c) 2005, 2008 Steven Levine and Associates, Inc.'
    88
    9 option stack = 65536
     9#option stack = 65536 # 14 Dec 08 SHL
     10option stack = 98304
  • trunk/dirsize.c

    r1220 r1341  
    1212  06 Jan 04 SHL Total drives >4GB better
    1313  08 Jul 08 SHL Avoid WARNALL warning
     14  14 Dec 08 SHL Add exception handler support
     15  14 Dec 08 SHL Drop NEVER used code
    1416
    1517***********************************************************************/
    1618
    1719#include <string.h>
    18 #include <ctype.h>
     20#include <ctype.h>                      // toupper
    1921
    2022#define INCL_DOS
    2123#define INCL_WIN
     24#define INCL_DOSEXCEPTIONS              // XCTP_...
     25#define INCL_DOSERRORS                  // NO_ERROR
    2226
    2327#include "dll\fm3dll.h"
    24 #include "dll\fm3dll2.h"                        // #define's for UM_*, control id's, etc.
    25 #include "dll\notebook.h"                       // Data declaration(s)
    26 #include "dll\info.h"                           // Data declaration(s)
    27 #include "dll\mainwnd.h"                        // Data declaration(s)
     28#include "dll\fm3dll2.h"                // #define's for UM_*, control id's, etc.
     29#include "dll\info.h"                   // driveflags
     30#include "dll\mainwnd.h"                // FM3ModHandle
    2831#include "dll\fm3dlg.h"
    29 #include "dll\valid.h"                          // CheckDrive
    30 #include "dll\init.h"                           // InitFM3DLL
    31 #include "dll\dirsize.h"                        // DirSizeProc
     32#include "dll\valid.h"                  // CheckDrive
     33#include "dll\init.h"                   // InitFM3DLL
     34#include "dll\dirsize.h"                // DirSizeProc
     35#include "dll\errutil.h"                // Error reporting
     36#include "dll\excputil.h"               // Exception handlers
     37
     38static PSZ pszSrcFile = __FILE__;
    3239
    3340MRESULT EXPENTRY DirMainProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     
    5562
    5663      for (x = 2; x < 26; x++) {
    57         if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    58           *dirname = (CHAR) x + 'A';
    59           WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_INSERTITEM,
    60                             MPFROM2SHORT(LIT_END, 0), MPFROMP(dirname));
    61           if (first) {
    62             WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_SELECTITEM,
    63                               MPFROMSHORT(0), MPFROMSHORT(TRUE));
    64             first = FALSE;
    65           }
    66         }
     64        if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
     65          *dirname = (CHAR) x + 'A';
     66          WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_INSERTITEM,
     67                            MPFROM2SHORT(LIT_END, 0), MPFROMP(dirname));
     68          if (first) {
     69            WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX, LM_SELECTITEM,
     70                              MPFROMSHORT(0), MPFROMSHORT(TRUE));
     71            first = FALSE;
     72          }
     73        }
    6774      }
    6875    }
     
    7986      struct
    8087      {
    81         ULONG serial;
    82         CHAR volumelength;
    83         CHAR volumelabel[CCHMAXPATH];
     88        ULONG serial;
     89        CHAR volumelength;
     90        CHAR volumelabel[CCHMAXPATH];
    8491      }
    8592      volser;
     
    96103      WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "");
    97104      WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
    98                         MPFROM2SHORT(SMA_SLIDERARMPOSITION,
    99                                      SMA_INCREMENTVALUE), MPFROMSHORT(0));
     105                        MPFROM2SHORT(SMA_SLIDERARMPOSITION,
     106                                     SMA_INCREMENTVALUE), MPFROMSHORT(0));
    100107      removable = CheckDrive(toupper(*curdir), FileSystem, &type);
    101108      if (removable != -1) {
    102         if (type & DRIVE_ZIPSTREAM)
    103           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Zipstream drive");
    104         else if (type & DRIVE_REMOTE)
    105           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Remote drive");
    106         else if (type & DRIVE_VIRTUAL)
    107             WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Virtual drive");
    108         else if (type & DRIVE_RAMDISK)
    109           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Ramdisk");
    110         else {
    111           sprintf(s, "Local drive%s", (removable) ? " (removable)" : "");
    112           WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, s);
    113         }
    114         sprintf(s, "IFS:  %s", FileSystem);
    115         WinSetDlgItemText(hwnd, DIRSIZE_IFS, s);
    116         memset(&volser, 0, sizeof(volser));
    117         DosError(FERR_DISABLEHARDERR);
    118         if (!DosQueryFSInfo(toupper(*curdir) - '@', FSIL_VOLSER,
    119                             &volser, (ULONG) sizeof(volser))) {
    120           sprintf(s, "Label:  %s", volser.volumelabel);
    121           WinSetDlgItemText(hwnd, DIRSIZE_LABEL, s);
    122         }
    123         if (!DosQueryFSInfo(toupper(*curdir) - '@',
    124                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    125           percentfree = fsa.cUnit ? (USHORT)((fsa.cUnitAvail * 100) / fsa.cUnit) : 0;   // 27 May 08 SHL
    126           if (!percentfree && fsa.cUnitAvail)
    127             percentfree = 1;
    128           percentused = 100 - percentfree;
    129           sprintf(s, "Units free:  %lu", fsa.cUnitAvail);
    130           WinSetDlgItemText(hwnd, DIRSIZE_UNITSFREE, s);
    131           sprintf(s, "Unit size:  %lu x %u = %lu",
    132                   fsa.cSectorUnit,
    133                   fsa.cbSector, fsa.cSectorUnit * fsa.cbSector);
    134           WinSetDlgItemText(hwnd, DIRSIZE_UNITSIZE, s);
    135           sprintf(s, "Units used:  %lu", fsa.cUnit - fsa.cUnitAvail);
    136           WinSetDlgItemText(hwnd, DIRSIZE_UNITSUSED, s);
    137           sprintf(s, "Bytes free:  %.0f",
    138                   (float)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector));
    139           WinSetDlgItemText(hwnd, DIRSIZE_BYTESFREE, s);
    140           sprintf(s, "Bytes used:  %.0f",
    141                   (float)(fsa.cUnit - fsa.cUnitAvail) *
    142                   (fsa.cSectorUnit * fsa.cbSector));
    143           WinSetDlgItemText(hwnd, DIRSIZE_BYTESUSED, s);
    144           sprintf(s, "Percent used:  %u%%", percentused);
    145           WinSetDlgItemText(hwnd, DIRSIZE_PERCENT, s);
    146           WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
    147                             MPFROM2SHORT(SMA_SLIDERARMPOSITION,
    148                                         SMA_INCREMENTVALUE),
    149                             MPFROMSHORT(percentused));
    150           WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), TRUE);
    151         }
     109        if (type & DRIVE_ZIPSTREAM)
     110          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Zipstream drive");
     111        else if (type & DRIVE_REMOTE)
     112          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Remote drive");
     113        else if (type & DRIVE_VIRTUAL)
     114            WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Virtual drive");
     115        else if (type & DRIVE_RAMDISK)
     116          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Ramdisk");
     117        else {
     118          sprintf(s, "Local drive%s", (removable) ? " (removable)" : "");
     119          WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, s);
     120        }
     121        sprintf(s, "IFS:  %s", FileSystem);
     122        WinSetDlgItemText(hwnd, DIRSIZE_IFS, s);
     123        memset(&volser, 0, sizeof(volser));
     124        DosError(FERR_DISABLEHARDERR);
     125        if (!DosQueryFSInfo(toupper(*curdir) - '@', FSIL_VOLSER,
     126                            &volser, (ULONG) sizeof(volser))) {
     127          sprintf(s, "Label:  %s", volser.volumelabel);
     128          WinSetDlgItemText(hwnd, DIRSIZE_LABEL, s);
     129        }
     130        if (!DosQueryFSInfo(toupper(*curdir) - '@',
     131                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     132          percentfree = fsa.cUnit ? (USHORT)((fsa.cUnitAvail * 100) / fsa.cUnit) : 0;   // 27 May 08 SHL
     133          if (!percentfree && fsa.cUnitAvail)
     134            percentfree = 1;
     135          percentused = 100 - percentfree;
     136          sprintf(s, "Units free:  %lu", fsa.cUnitAvail);
     137          WinSetDlgItemText(hwnd, DIRSIZE_UNITSFREE, s);
     138          sprintf(s, "Unit size:  %lu x %u = %lu",
     139                  fsa.cSectorUnit,
     140                  fsa.cbSector, fsa.cSectorUnit * fsa.cbSector);
     141          WinSetDlgItemText(hwnd, DIRSIZE_UNITSIZE, s);
     142          sprintf(s, "Units used:  %lu", fsa.cUnit - fsa.cUnitAvail);
     143          WinSetDlgItemText(hwnd, DIRSIZE_UNITSUSED, s);
     144          sprintf(s, "Bytes free:  %.0f",
     145                  (float)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector));
     146          WinSetDlgItemText(hwnd, DIRSIZE_BYTESFREE, s);
     147          sprintf(s, "Bytes used:  %.0f",
     148                  (float)(fsa.cUnit - fsa.cUnitAvail) *
     149                  (fsa.cSectorUnit * fsa.cbSector));
     150          WinSetDlgItemText(hwnd, DIRSIZE_BYTESUSED, s);
     151          sprintf(s, "Percent used:  %u%%", percentused);
     152          WinSetDlgItemText(hwnd, DIRSIZE_PERCENT, s);
     153          WinSendDlgItemMsg(hwnd, DIRSIZE_SLIDER, SLM_SETSLIDERINFO,
     154                            MPFROM2SHORT(SMA_SLIDERARMPOSITION,
     155                                        SMA_INCREMENTVALUE),
     156                            MPFROMSHORT(percentused));
     157          WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), TRUE);
     158        }
    152159      }
    153160      else {
    154         WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Drive not ready.");
    155         WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), FALSE);
     161        WinSetDlgItemText(hwnd, DIRSIZE_LOCAL, "Drive not ready.");
     162        WinShowWindow(WinWindowFromID(hwnd, DIRSIZE_SLIDER), FALSE);
    156163      }
    157164    }
     
    163170      switch (SHORT2FROMMP(mp1)) {
    164171      case LN_ENTER:
    165         WinPostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
    166         break;
     172        WinPostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
     173        break;
    167174      case LN_SELECT:
    168         {
    169           SHORT x;
    170 
    171           x = (SHORT) WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
    172                                         LM_QUERYSELECTION,
    173                                         MPFROMSHORT(LIT_FIRST), MPVOID);
    174           if (x >= 0) {
    175             WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
    176                               LM_QUERYITEMTEXT,
    177                               MPFROM2SHORT(x, sizeof(curdir)),
    178                               MPFROMP(curdir));
    179             WinPostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    180           }
    181         }
    182         break;
     175        {
     176          SHORT x;
     177
     178          x = (SHORT) WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
     179                                        LM_QUERYSELECTION,
     180                                        MPFROMSHORT(LIT_FIRST), MPVOID);
     181          if (x >= 0) {
     182            WinSendDlgItemMsg(hwnd, DIRSIZE_LISTBOX,
     183                              LM_QUERYITEMTEXT,
     184                              MPFROM2SHORT(x, sizeof(curdir)),
     185                              MPFROMP(curdir));
     186            WinPostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     187          }
     188        }
     189        break;
    183190      }
    184191      break;
     
    194201    case DID_OK:
    195202      if (*curdir) {
    196         WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_HIDE);
    197         WinDlgBox(HWND_DESKTOP, hwnd,
    198                   DirSizeProc, FM3ModHandle, DSZ_FRAME, curdir);
    199         WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOW);
     203        WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_HIDE);
     204        WinDlgBox(HWND_DESKTOP, hwnd,
     205                  DirSizeProc, FM3ModHandle, DSZ_FRAME, curdir);
     206        WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOW);
    200207      }
    201208      else
    202         DosBeep(50, 100);
     209        DosBeep(50, 100);
    203210      break;
    204211    }
    205212    return 0;
    206   }                                     // switch
     213  } // switch
    207214  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    208215}
    209 
    210 #ifdef NEVER                            // 05 Jan 08 SHL fixme to be gone?
    211 
    212 VOID APIENTRY deinit(ULONG why)
    213 {
    214   if (fmprof)
    215     PrfCloseProfile(fmprof);
    216   fmprof = (HINI) 0;
    217 
    218   flushall();
    219 
    220   DosExitList(EXLST_REMOVE, deinit);
    221 }
    222 
    223 #endif
    224216
    225217int main(int argc, char *argv[])
     
    227219  HAB hab;
    228220  HMQ hmq;
    229   static CHAR fullname[CCHMAXPATH];
    230   INT x;
     221  CHAR fullname[CCHMAXPATH] = { 0 };    // 14 Dec 08 SHL was static
     222  UINT x;
    231223  ULONG rcl;
     224  APIRET regRet;
     225  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    232226
    233227  DosError(FERR_DISABLEHARDERR);
    234   *fullname = 0;
     228
     229  regRec.ExceptionHandler = HandleException;
     230  regRet = DosSetExceptionHandler(&regRec);
     231  if (regRet != NO_ERROR) {
     232    DbgMsg(pszSrcFile, __LINE__,
     233           "DosSetExceptionHandler failed with error %u", regRet);
     234  }
     235
    235236  for (x = 1; x < argc; x++) {
    236237    if (!strchr("/;,`\'", *argv[x]) &&
    237         !*fullname && (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
     238        !*fullname && (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
    238239      if (IsRoot(argv[x]))
    239         strcpy(fullname, argv[x]);
     240        strcpy(fullname, argv[x]);
    240241      else if (DosQueryPathInfo(argv[x],
    241                                 FIL_QUERYFULLNAME,
    242                                 fullname, sizeof(fullname)))
    243         *fullname = 0;
     242                                FIL_QUERYFULLNAME,
     243                                fullname, sizeof(fullname)))
     244        *fullname = 0;                  // Forget name
    244245    }
    245246  }
    246 
    247 # ifdef NEVER
    248   DosExitList(EXLST_ADD, deinit);
    249 # endif
    250247
    251248  hab = WinInitialize(0);
     
    254251    if (hmq) {
    255252      if (InitFM3DLL(hab, argc, argv)) {
    256         if (!*fullname)
    257           rcl = WinDlgBox(HWND_DESKTOP,
    258                           HWND_DESKTOP, DirMainProc, 0, DIRSIZE_FRAME, NULL);
    259         else
    260           rcl = WinDlgBox(HWND_DESKTOP,
    261                           HWND_DESKTOP,
    262                           DirSizeProc, FM3ModHandle, DSZ_FRAME, fullname);
    263         if (rcl == DID_ERROR)
    264           rcl = WinGetLastError(hab);
     253        if (!*fullname)
     254          rcl = WinDlgBox(HWND_DESKTOP,
     255                          HWND_DESKTOP, DirMainProc, 0, DIRSIZE_FRAME, NULL);
     256        else
     257          rcl = WinDlgBox(HWND_DESKTOP,
     258                          HWND_DESKTOP,
     259                          DirSizeProc, FM3ModHandle, DSZ_FRAME, fullname);
     260        if (rcl == DID_ERROR)
     261          rcl = WinGetLastError(hab);
    265262      }
    266263      WinDestroyMsgQueue(hmq);
     
    270267  return 0;
    271268
    272 }                                       // main
     269} // main
  • trunk/eas.c

    r1215 r1341  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2002, 2007 Steven H.Levine
     9  Copyright (c) 2002, 2008 Steven H.Levine
    1010
    1111  16 Oct 02 SHL Reformat
     
    1414  08 Apr 07 SHL Minor reformat
    1515  10 May 08 SHL Correct compare typo
     16  14 Dec 08 SHL Add exception handler support
    1617
    1718***********************************************************************/
    1819
    19 #include <stdlib.h>
    2020#include <string.h>
    2121
    2222#define INCL_DOS
    2323#define INCL_WIN
     24#define INCL_DOSEXCEPTIONS              // XCTP_...
     25#define INCL_DOSERRORS                  // NO_ERROR
    2426
    2527#include "dll\fm3dll.h"
    26 #include "dll\notebook.h"                       // Data declaration(s)
    27 #include "dll\mainwnd.h"                        // Data declaration(s)
     28#include "dll\mainwnd.h"                // FM3ModHandle
    2829#include "dll\fm3dlg.h"
    29 #include "dll\makelist.h"
     30#include "dll\makelist.h"               // AddToList
    3031#include "dll\eas.h"                    // DisplayEAsProc
    3132#include "dll\init.h"                   // InitFM3DLL
    3233#include "dll\valid.h"                  // IsFile
    33 #include "dll\wrappers.h"                       // xfree
    34 #include "dll\getnames.h"                       // insert_filename
     34#include "dll\wrappers.h"               // xfree
     35#include "dll\getnames.h"               // insert_filename
     36#include "dll\errutil.h"                // Error reporting
     37#include "dll\excputil.h"               // Exception handlers
    3538
    3639static PSZ pszSrcFile = __FILE__;
     
    4245  CHAR fullname[CCHMAXPATH];
    4346  CHAR **list = NULL;
    44   UINT x,numfiles = 0,numalloc = 0;
     47  UINT x;
     48  UINT numfiles = 0;
     49  UINT numalloc = 0;
     50  APIRET regRet;
     51  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    4552
    4653  DosError(FERR_DISABLEHARDERR);
     54
     55  regRec.ExceptionHandler = HandleException;
     56  regRet = DosSetExceptionHandler(&regRec);
     57  if (regRet != NO_ERROR) {
     58    DbgMsg(pszSrcFile, __LINE__,
     59           "DosSetExceptionHandler failed with error %u", regRet);
     60  }
     61
    4762  for(x = 1; x < argc; x++) {
    4863    if (!strchr("/;,`\'",*argv[x]) && IsFile(argv[x]) != -1) {
     
    5469    }
    5570  }
     71
    5672  hab = WinInitialize(0);
    5773  if (hab) {
  • trunk/fm3.c

    r1336 r1341  
    2424
    2525#include "dll\fm3dll.h"
    26 #include "dll\mainwnd.h"                // Data declaration(s)
    27 #include "dll\tools.h"
    28 #include "dll\version.h"
    29 #include "dll\errutil.h"
     26#include "dll\mainwnd.h"                // hwndBubble
     27#include "dll\version.h"                // VER...
     28#include "dll\init.h"                   // StartFM3
     29#include "dll\notebook.h"               // appname
    3030#include "dll\fortify.h"
    31 #include "dll\init.h"                   // StartFM3
    32 #include "dll\notebook.h"               // Data declaration(s)
    3331#include "dll\errutil.h"                // Error reporting
    3432#include "dll\excputil.h"               // Exception handlers
     
    9997              break;
    10098          }
    101           Fortify_DumpAllMemory();
     99          Fortify_DumpAllMemory();
    102100#         endif
    103101        }
  • trunk/fm4.c

    r1215 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1819#define INCL_WIN
    1920#define INCL_LONGLONG
     21#define INCL_DOSEXCEPTIONS              // XCTP_...
     22#define INCL_DOSERRORS                  // NO_ERROR
    2023
    2124#include "dll\fm3dll.h"
    22 #include "dll\mainwnd.h"                // Data declaration(s)
    23 #include "dll\notebook.h"               // Data declaration(s)
     25#include "dll\mainwnd.h"                // hwndBubble
     26#include "dll\notebook.h"               // appname
    2427#include "dll\tools.h"
    2528#include "dll\version.h"
    2629#include "dll\mainwnd2.h"               // StartFM32
    2730#include "dll\init.h"                   // InitFM3DLL
     31#include "dll\errutil.h"                // Error reporting
     32#include "dll\excputil.h"               // Exception handlers
     33
     34static PSZ pszSrcFile = __FILE__;
    2835
    2936int main(int argc, char *argv[])
     
    3340  QMSG qmsg;
    3441  HWND hwndFrame;
     42  APIRET regRet;
     43  UINT x;
     44  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3545
    3646  strcpy(appname, "FM/4");
    37   {
    38     INT x;
     47  DosError(FERR_DISABLEHARDERR);
    3948
    40     for (x = 1; x < argc; x++) {
    41       if (*argv[x] == '+' && !argv[x][1])
    42         fLogFile = TRUE;
    43       if (*argv[x] == '-') {
    44         if (argv[x][1])
    45           strcpy(profile, &argv[x][1]);
    46       }
     49  regRec.ExceptionHandler = HandleException;
     50  regRet = DosSetExceptionHandler(&regRec);
     51  if (regRet != NO_ERROR) {
     52    DbgMsg(pszSrcFile, __LINE__,
     53           "DosSetExceptionHandler failed with error %u", regRet);
     54  }
     55
     56  for (x = 1; x < argc; x++) {
     57    if (*argv[x] == '+' && !argv[x][1])
     58      fLogFile = TRUE;
     59    if (*argv[x] == '-') {
     60      if (argv[x][1])
     61        strcpy(profile, &argv[x][1]);
    4762    }
    4863  }
    49   DosError(FERR_DISABLEHARDERR);
     64
    5065  hab = WinInitialize(0);
    5166  if (hab) {
  • trunk/global.c

    r1215 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1718#define INCL_DOS
    1819#define INCL_WIN
     20#define INCL_DOSEXCEPTIONS              // XCTP_...
     21#define INCL_DOSERRORS                  // NO_ERROR
    1922
    2023#include "dll\fm3dll.h"
    21 #include "dll\mainwnd.h"                // Data declaration(s)
    22 #include "dll\notebook.h"               // Data declaration(s)
     24#include "dll\mainwnd.h"                // hwndBubble
     25#include "dll\notebook.h"               // appname
    2326#include "dll\fm3str.h"
    24 #include "dll\seeall.h"                 // StartSeeAll
     27#include "dll\seeall.h"                 // StartSeeAll
    2528#include "dll\valid.h"                  // IsFile
    2629#include "dll\init.h"                   // InitFM3DLL
     30#include "dll\errutil.h"                // Error reporting
     31#include "dll\excputil.h"               // Exception handlers
     32
     33static PSZ pszSrcFile = __FILE__;
    2734
    2835int main(int argc, char *argv[])
     
    3239  QMSG qmsg;
    3340  HWND hwndFrame;
    34   static CHAR fullname[CCHMAXPATH];
    35   INT x;
     41  CHAR fullname[CCHMAXPATH] = { 0 };    // 14 Dec 08 SHL was static
     42  UINT x;
     43  APIRET regRet;
     44  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3645
    37   *fullname = 0;
    3846  strcpy(appname, "SEEALL");
    3947  DosError(FERR_DISABLEHARDERR);
     48
     49  regRec.ExceptionHandler = HandleException;
     50  regRet = DosSetExceptionHandler(&regRec);
     51  if (regRet != NO_ERROR) {
     52    DbgMsg(pszSrcFile, __LINE__,
     53           "DosSetExceptionHandler failed with error %u", regRet);
     54  }
     55
    4056  hab = WinInitialize(0);
    4157  if (hab) {
     
    4359    if (hmq) {
    4460      if (InitFM3DLL(hab, argc, argv)) {
    45         for (x = 1; x < argc; x++) {
    46           if (!strchr("/;,`\'", *argv[x]) && !*fullname &&
    47               (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
    48             if (IsRoot(argv[x]))
    49               strcpy(fullname, argv[x]);
    50             else if (DosQueryPathInfo(argv[x],
    51                                       FIL_QUERYFULLNAME,
    52                                       fullname, sizeof(fullname)))
    53               *fullname = 0;
    54           }
    55         }
    56         hwndFrame = StartSeeAll(HWND_DESKTOP, TRUE, fullname);
    57         if (hwndFrame) {
    58           for (;;) {
    59             if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
    60               if (qmsg.hwnd)
    61                 qmsg.msg = WM_CLOSE;
    62               else
    63                 break;
    64             }
    65             if (hwndBubble &&
    66                 ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
    67                   qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
    68                 (qmsg.msg > (WM_CHORD - 1) &&
    69                   qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
    70                 WinIsWindowVisible(hwndBubble))
    71               WinShowWindow(hwndBubble, FALSE);
    72             WinDispatchMsg(hab, &qmsg);
    73           }
    74           DosSleep(125L);
    75         }
     61        for (x = 1; x < argc; x++) {
     62          if (!strchr("/;,`\'", *argv[x]) && !*fullname &&
     63              (IsRoot(argv[x]) || IsFile(argv[x]) == 0)) {
     64            if (IsRoot(argv[x]))
     65              strcpy(fullname, argv[x]);
     66            else if (DosQueryPathInfo(argv[x],
     67                                      FIL_QUERYFULLNAME,
     68                                      fullname, sizeof(fullname)))
     69              *fullname = 0;            // Forget name
     70          }
     71        }
     72        hwndFrame = StartSeeAll(HWND_DESKTOP, TRUE, fullname);
     73        if (hwndFrame) {
     74          for (;;) {
     75            if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
     76              if (qmsg.hwnd)
     77                qmsg.msg = WM_CLOSE;
     78              else
     79                break;
     80            }
     81            if (hwndBubble &&
     82                ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
     83                  qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
     84                (qmsg.msg > (WM_CHORD - 1) &&
     85                  qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
     86                WinIsWindowVisible(hwndBubble))
     87              WinShowWindow(hwndBubble, FALSE);
     88            WinDispatchMsg(hab, &qmsg);
     89          }
     90          DosSleep(125L);
     91        }
    7692      }
    7793      DosSleep(125L);
  • trunk/ini.c

    r1215 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1516#define INCL_DOS
    1617#define INCL_WIN
     18#define INCL_DOSEXCEPTIONS              // XCTP_...
     19#define INCL_DOSERRORS                  // NO_ERROR
    1720
    1821#include "dll\fm3dll.h"
    19 #include "dll\notebook.h"               // Data declaration(s)
     22#include "dll\notebook.h"               // hwndHelp
    2023#include "dll\init.h"                   // InitFM3DLL
    2124#include "dll\inis.h"                   // StartIniEditor
     25#include "dll\errutil.h"                // Error reporting
     26#include "dll\excputil.h"               // Exception handlers
     27
     28static PSZ pszSrcFile = __FILE__;
    2229
    2330int main(int argc, char *argv[])
     
    2734  QMSG qmsg;
    2835  HWND hwndFrame;
     36  APIRET regRet;
     37  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    2938
    3039  DosError(FERR_DISABLEHARDERR);
     40
     41  regRec.ExceptionHandler = HandleException;
     42  regRet = DosSetExceptionHandler(&regRec);
     43  if (regRet != NO_ERROR) {
     44    DbgMsg(pszSrcFile, __LINE__,
     45           "DosSetExceptionHandler failed with error %u", regRet);
     46  }
     47
    3148  hab = WinInitialize(0);
    3249  if (hab) {
  • trunk/killproc.c

    r1215 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1516#define INCL_DOS
    1617#define INCL_WIN
     18#define INCL_DOSEXCEPTIONS              // XCTP_...
     19#define INCL_DOSERRORS                  // NO_ERROR
    1720
    1821#include "dll\fm3dll.h"
    19 #include "dll\mainwnd.h"                        // Data declaration(s)
     22#include "dll\mainwnd.h"                // FM3ModHandle
    2023#include "dll\fm3dlg.h"
    21 #include "dll\init.h"                           // InitFM3DLL
    22 #include "dll\killproc.h"                       // KillDlgProc
     24#include "dll\init.h"                   // InitFM3DLL
     25#include "dll\killproc.h"               // KillDlgProc
     26#include "dll\errutil.h"                // Error reporting
     27#include "dll\excputil.h"               // Exception handlers
     28
     29static PSZ pszSrcFile = __FILE__;
    2330
    2431int main(int argc, char *argv[])
     
    2633  HAB hab;
    2734  HMQ hmq;
     35  APIRET regRet;
     36  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    2837
    2938  DosError(FERR_DISABLEHARDERR);
     39
     40  regRec.ExceptionHandler = HandleException;
     41  regRet = DosSetExceptionHandler(&regRec);
     42  if (regRet != NO_ERROR) {
     43    DbgMsg(pszSrcFile, __LINE__,
     44           "DosSetExceptionHandler failed with error %u", regRet);
     45  }
     46
    3047  hab = WinInitialize(0);
    3148  if (hab) {
     
    3350    if (hmq) {
    3451      if (InitFM3DLL(hab, argc, argv)) {
    35         WinDlgBox(HWND_DESKTOP,
    36                   HWND_DESKTOP, KillDlgProc, FM3ModHandle, KILL_FRAME, NULL);
     52        WinDlgBox(HWND_DESKTOP,
     53                  HWND_DESKTOP, KillDlgProc, FM3ModHandle, KILL_FRAME, NULL);
    3754      }
    3855      DosSleep(250L);
  • trunk/sysinfo.c

    r1216 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
    1415
    15 #define INCL_DOS
    1616#define INCL_WIN
     17#define INCL_DOSEXCEPTIONS              // XCTP_...
     18#define INCL_DOSERRORS                  // NO_ERROR
    1719
    1820#include "dll\fm3dll.h"
    19 #include "dll\mainwnd.h"                        // Data declaration(s)
     21#include "dll\mainwnd.h"                // FM3ModHandle
    2022#include "dll\fm3dlg.h"
    21 #include "dll\init.h"                           // InitFM3DLL
    22 #include "dll\sysinfo.h"                        // SysInfoDlgProc
     23#include "dll\init.h"                   // InitFM3DLL
     24#include "dll\sysinfo.h"                // SysInfoDlgProc
     25#include "dll\errutil.h"                // Error reporting
     26#include "dll\excputil.h"               // Exception handlers
     27
     28static PSZ pszSrcFile = __FILE__;
    2329
    2430int main(int argc, char *argv[])
     
    2632  HAB hab;
    2733  HMQ hmq;
     34  APIRET regRet;
     35  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
     36
     37  regRec.ExceptionHandler = HandleException;
     38  regRet = DosSetExceptionHandler(&regRec);
     39  if (regRet != NO_ERROR) {
     40    DbgMsg(pszSrcFile, __LINE__,
     41           "DosSetExceptionHandler failed with error %u", regRet);
     42  }
    2843
    2944  hab = WinInitialize(0);
     
    3247    if (hmq) {
    3348      if (InitFM3DLL(hab, argc, argv)) {
    34         WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
    35                   SysInfoDlgProc, FM3ModHandle, SYS_FRAME, NULL);
     49        WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
     50                  SysInfoDlgProc, FM3ModHandle, SYS_FRAME, NULL);
    3651      }
    3752      WinDestroyMsgQueue(hmq);
  • trunk/undel.c

    r1216 r1341  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2007 Steven H. Levine
     9  Copyright (c) 2007, 2008 Steven H. Levine
    1010
    1111  23 Sep 07 SHL Sync with standards
    1212  23 Sep 07 SHL Get rid of statics
     13  14 Dec 08 SHL Add exception handler support
    1314
    1415***********************************************************************/
     
    1718
    1819#define INCL_DOS
     20#define INCL_DOSEXCEPTIONS              // XCTP_...
     21#define INCL_DOSERRORS                  // NO_ERROR
    1922
    2023#include "dll\fm3dll.h"
    21 #include "dll\mainwnd.h"                // Data declaration(s)
     24#include "dll\mainwnd.h"                // FM3ModHandle
    2225#include "dll\fm3dlg.h"
    2326#include "dll\undel.h"                  // UndeleteDlgProc
     
    2528#include "dll\valid.h"                  // MakeValidDir
    2629#include "dll\dirs.h"                   // save_dir
     30#include "dll\errutil.h"                // Error reporting
     31#include "dll\excputil.h"               // Exception handlers
     32
     33static PSZ pszSrcFile = __FILE__;
    2734
    2835int main(int argc, char *argv[])
     
    3239  FILESTATUS3 fs;
    3340  CHAR fullname[CCHMAXPATH];
    34   CHAR *thisarg = NULL;
    35   INT x;
     41  PSZ thisarg = NULL;
     42  UINT x;
     43  APIRET regRet;
     44  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3645
    3746  DosError(FERR_DISABLEHARDERR);
     47
     48  regRec.ExceptionHandler = HandleException;
     49  regRet = DosSetExceptionHandler(&regRec);
     50  if (regRet != NO_ERROR) {
     51    DbgMsg(pszSrcFile, __LINE__,
     52           "DosSetExceptionHandler failed with error %u", regRet);
     53  }
     54
    3855  for (x = 1; x < argc; x++) {
    3956    if (!strchr("/;,`\'", *argv[x]) && !thisarg) {
  • trunk/vcollect.c

    r1229 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1718#define INCL_DOS
    1819#define INCL_WIN
     20#define INCL_DOSEXCEPTIONS              // XCTP_...
     21#define INCL_DOSERRORS                  // NO_ERROR
    1922
    2023#include "dll\fm3dll.h"
    21 #include "dll\fm3dll2.h"                // #define's for UM_*, control id's, etc.
     24#include "dll\fm3dll2.h"                // IDM_GREP
    2225#include "dll\mainwnd.h"                // Data declaration(s)
    2326#include "dll\notebook.h"               // Data declaration(s)
     
    2528#include "dll\init.h"                   // InitFM3DLL
    2629#include "dll\collect.h"                // StartCollector
     30#include "dll\errutil.h"                // Error reporting
     31#include "dll\excputil.h"               // Exception handlers
     32
     33static PSZ pszSrcFile = __FILE__;
    2734
    2835int main(int argc, char *argv[])
     
    3239  QMSG qmsg;
    3340  HWND hwndFrame;
    34   int x;
     41  UINT x;
    3542  BOOL seekandscan = FALSE;
     43  APIRET regRet;
     44  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3645
    3746  strcpy(appname, "VCOLLECT");
    3847  DosError(FERR_DISABLEHARDERR);
     48
     49  regRec.ExceptionHandler = HandleException;
     50  regRet = DosSetExceptionHandler(&regRec);
     51  if (regRet != NO_ERROR) {
     52    DbgMsg(pszSrcFile, __LINE__,
     53           "DosSetExceptionHandler failed with error %u", regRet);
     54  }
     55
    3956  for (x = 1; x < argc; x++) {
    4057    if (*argv[x] == '*' && argv[x][1] == '*') {
     
    4360    }
    4461  }
     62
    4563  hab = WinInitialize(0);
    4664  if (hab) {
  • trunk/vdir.c

    r1216 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
     
    1718#define INCL_DOS
    1819#define INCL_WIN
     20#define INCL_DOSEXCEPTIONS              // XCTP_...
     21#define INCL_DOSERRORS                  // NO_ERROR
    1922
    2023#include "dll\fm3dll.h"
    21 #include "dll\mainwnd.h"                // Data declaration(s)
    22 #include "dll\notebook.h"               // Data declaration(s)
     24#include "dll\mainwnd.h"                // hwndHelp
     25#include "dll\notebook.h"               // appname
    2326#include "dll\init.h"                   // InitFM3DLL
    2427#include "dll\valid.h"                  // IsFile
    2528#include "dll\dirs.h"                   // save_dir
     29#include "dll\errutil.h"                // Error reporting
     30#include "dll\excputil.h"               // Exception handlers
     31
     32static PSZ pszSrcFile = __FILE__;
    2633
    2734int main(int argc, char *argv[])
     
    3138  QMSG qmsg;
    3239  HWND hwndFrame;
    33   CHAR fullname[CCHMAXPATH], *thisarg = NULL;
    34   INT x;
     40  CHAR fullname[CCHMAXPATH];
     41  PSZ thisarg = NULL;
     42  UINT x;
     43  APIRET regRet;
     44  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3545
    3646  strcpy(appname, "VDIR");
    3747  DosError(FERR_DISABLEHARDERR);
     48
     49  regRec.ExceptionHandler = HandleException;
     50  regRet = DosSetExceptionHandler(&regRec);
     51  if (regRet != NO_ERROR) {
     52    DbgMsg(pszSrcFile, __LINE__,
     53           "DosSetExceptionHandler failed with error %u", regRet);
     54  }
     55
    3856  for (x = 1; x < argc; x++) {
    3957    if (!strchr("/;,`\'", *argv[x]) && (IsRoot(argv[x]) || !IsFile(argv[x]))) {
     
    5068  else
    5169    save_dir(fullname);
     70
    5271  hab = WinInitialize(0);
    5372  if (hab) {
  • trunk/viewinfs.c

    r1216 r1341  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2007 Steven H.Levine
     9  Copyright (c) 2007, 2008 Steven H.Levine
    1010
    1111  03 Aug 07 SHL Minor cleanup
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
    1415
    15 #define INCL_DOS                        // DosSleep
     16#define INCL_DOS                        // DosSleep
    1617#define INCL_WIN
     18#define INCL_DOSEXCEPTIONS              // XCTP_...
     19#define INCL_DOSERRORS                  // NO_ERROR
    1720
    1821#include "dll\fm3dll.h"
    19 #include "dll\notebook.h"                       // Data declaration(s)
    20 #include "dll\mainwnd.h"                        // Data declaration(s)
     22#include "dll\notebook.h"               // appname
     23#include "dll\mainwnd.h"                // FM3ModHandle
    2124#include "dll\fm3dlg.h"
    22 #include "dll\init.h"                           // InitFM3DLL
    23 #include "dll\viewinf.h"                        // ViewInfProc
     25#include "dll\init.h"                   // InitFM3DLL
     26#include "dll\viewinf.h"                // ViewInfProc
     27#include "dll\errutil.h"                // Error reporting
     28#include "dll\excputil.h"               // Exception handlers
     29
     30static PSZ pszSrcFile = __FILE__;
    2431
    2532int main(int argc, char *argv[])
     
    2734  HAB hab;
    2835  HMQ hmq;
     36  APIRET regRet;
     37  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
     38
     39  regRec.ExceptionHandler = HandleException;
     40  regRet = DosSetExceptionHandler(&regRec);
     41  if (regRet != NO_ERROR) {
     42    DbgMsg(pszSrcFile, __LINE__,
     43           "DosSetExceptionHandler failed with error %u", regRet);
     44  }
    2945
    3046  hab = WinInitialize(0);
     
    3349    if (hmq) {
    3450      if (InitFM3DLL(hab, argc, argv)) {
    35         WinDlgBox(HWND_DESKTOP,
    36                   HWND_DESKTOP,
    37                   ViewInfProc,
    38                   FM3ModHandle,
    39                   VINF_FRAME, ((argc > 1) ? MPFROMP("") : MPVOID));
     51        WinDlgBox(HWND_DESKTOP,
     52                  HWND_DESKTOP,
     53                  ViewInfProc,
     54                  FM3ModHandle,
     55                  VINF_FRAME, ((argc > 1) ? MPFROMP("") : MPVOID));
    4056      }
    4157      DosSleep(250);
  • trunk/vtree.c

    r1216 r1341  
    1010
    1111  05 Jan 08 SHL Sync
     12  14 Dec 08 SHL Add exception handler support
    1213
    1314***********************************************************************/
    1415
    15 #include <stdlib.h>
     16#include <stdlib.h>                     // min
    1617#include <string.h>
    1718
    1819#define INCL_DOS
    1920#define INCL_WIN
     21#define INCL_DOSEXCEPTIONS              // XCTP_...
     22#define INCL_DOSERRORS                  // NO_ERROR
    2023
    2124#include "dll\fm3dll.h"
    22 #include "dll\mainwnd.h"                // Data declaration(s)
    23 #include "dll\notebook.h"               // Data declaration(s)
     25#include "dll\mainwnd.h"                // hwndTree hwndBubble
     26#include "dll\notebook.h"               // appname
    2427#include "dll\init.h"                   // InitFM3DLL
    25 #include "dll\treecnr.h"                // StartTreeCnr
     28#include "dll\treecnr.h"                // StartTreeCnr
     29#include "dll\errutil.h"                // Error reporting
     30#include "dll\excputil.h"               // Exception handlers
     31
     32static PSZ pszSrcFile = __FILE__;
    2633
    2734int main(int argc, char *argv[])
     
    3037  HMQ hmq;
    3138  QMSG qmsg;
    32   INT x;
     39  UINT x;
    3340  BOOL startminimized = FALSE;
     41  APIRET regRet;
     42  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3443
    3544  strcpy(appname, "VTREE");
    3645  DosError(FERR_DISABLEHARDERR);
     46
     47  regRec.ExceptionHandler = HandleException;
     48  regRet = DosSetExceptionHandler(&regRec);
     49  if (regRet != NO_ERROR) {
     50    DbgMsg(pszSrcFile, __LINE__,
     51           "DosSetExceptionHandler failed with error %u", regRet);
     52  }
     53
    3754  hab = WinInitialize(0);
    3855  if (hab) {
     
    4057    if (hmq) {
    4158      if (InitFM3DLL(hab, argc, argv)) {
    42         for (x = 1; x < argc; x++) {
    43           if (*argv[x] == '~') {
    44             startminimized = TRUE;
    45             break;
    46           }
    47         }
    48         hwndTree = StartTreeCnr(HWND_DESKTOP, 0);
    49         if (hwndTree) {
    50           if (hwndHelp)
    51             WinAssociateHelpInstance(hwndHelp, hwndTree);
    52           if (!WinRestoreWindowPos("FM/2", "VTreeWindowPos", hwndTree)) {
     59        for (x = 1; x < argc; x++) {
     60          if (*argv[x] == '~') {
     61            startminimized = TRUE;
     62            break;
     63          }
     64        }
     65        hwndTree = StartTreeCnr(HWND_DESKTOP, 0);
     66        if (hwndTree) {
     67          if (hwndHelp)
     68            WinAssociateHelpInstance(hwndHelp, hwndTree);
     69          if (!WinRestoreWindowPos("FM/2", "VTreeWindowPos", hwndTree)) {
    5370
    54             SWP swp;
    55             ULONG adjust;
     71            SWP swp;
     72            ULONG adjust;
    5673
    57             adjust = WinQuerySysValue(HWND_DESKTOP, SV_CXICON) * 8L;
    58             WinQueryTaskSizePos(hab, 0L, &swp);
    59             swp.cx = min(swp.cx, adjust);
    60             WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    61                             SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER |
    62                             SWP_ACTIVATE);
    63           }
    64           if (startminimized)
    65             WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE);
    66           else
    67             WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0,
    68                             SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
    69           for (;;) {
    70             if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
    71               if (qmsg.hwnd)
    72                 qmsg.msg = WM_CLOSE;
    73               else
    74                 break;
    75             }
    76             if (hwndBubble &&
    77                 ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
    78                   qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
    79                 (qmsg.msg > (WM_CHORD - 1) &&
    80                   qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
    81                 WinIsWindowVisible(hwndBubble))
    82               WinShowWindow(hwndBubble, FALSE);
    83             WinDispatchMsg(hab, &qmsg);
    84           }
    85         }
     74            adjust = WinQuerySysValue(HWND_DESKTOP, SV_CXICON) * 8L;
     75            WinQueryTaskSizePos(hab, 0L, &swp);
     76            swp.cx = min(swp.cx, adjust);
     77            WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     78                            SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER |
     79                            SWP_ACTIVATE);
     80          }
     81          if (startminimized)
     82            WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE);
     83          else
     84            WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0,
     85                            SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
     86          for (;;) {
     87            if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
     88              if (qmsg.hwnd)
     89                qmsg.msg = WM_CLOSE;
     90              else
     91                break;
     92            }
     93            if (hwndBubble &&
     94                ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
     95                  qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
     96                (qmsg.msg > (WM_CHORD - 1) &&
     97                  qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
     98                WinIsWindowVisible(hwndBubble))
     99              WinShowWindow(hwndBubble, FALSE);
     100            WinDispatchMsg(hab, &qmsg);
     101          }
     102        }
    86103      }
    87104      DosSleep(125);
Note: See TracChangeset for help on using the changeset viewer.