home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
c
/
coolcolr.zip
/
ERROR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
6KB
|
127 lines
//****************************************************************************
// File: ERROR.C
//
// Purpose: Contains the error routines for this program
//
// Functions: void FAR ProcessCDError(DWORD)
// void FAR ReportError(WORD)
//
// Development Team:
//
// Greg Keyser
//
// Written by Microsoft Product Support Services, Windows Developer Support
// Copyright (c) 1992 Microsoft Corporation. All rights reserved.
//****************************************************************************
#define WIN31
#include "windows.h"
#include "commdlg.h"
#include "cderr.h"
#include "global.h"
//****************************************************************************
//
// Function: ProcessCDError(DWORD)
//
// Purpose: To report an error that has occurred during the last
// call to a CD routine.
//
// Returns: void
//
// Comments:
//
// History: Date Reason
// -------- -----------------------------------
//
// 10/01/91 Created
//
//****************************************************************************
void FAR PASCAL ProcessCDError(DWORD dwErrorCode)
{
WORD wStringID;
char szString[128];
switch(dwErrorCode)
{
case CDERR_DIALOGFAILURE: wStringID=IDS_DIALOGFAILURE; break;
case CDERR_STRUCTSIZE: wStringID=IDS_STRUCTSIZE; break;
case CDERR_INITIALIZATION: wStringID=IDS_INITIALIZATION; break;
case CDERR_NOTEMPLATE: wStringID=IDS_NOTEMPLATE; break;
case CDERR_NOHINSTANCE: wStringID=IDS_NOHINSTANCE; break;
case CDERR_LOADSTRFAILURE: wStringID=IDS_LOADSTRFAILURE; break;
case CDERR_FINDRESFAILURE: wStringID=IDS_FINDRESFAILURE; break;
case CDERR_LOADRESFAILURE: wStringID=IDS_LOADRESFAILURE; break;
case CDERR_LOCKRESFAILURE: wStringID=IDS_LOCKRESFAILURE; break;
case CDERR_MEMALLOCFAILURE: wStringID=IDS_MEMALLOCFAILURE; break;
case CDERR_MEMLOCKFAILURE: wStringID=IDS_MEMLOCKFAILURE; break;
case CDERR_NOHOOK: wStringID=IDS_NOHOOK; break;
case PDERR_SETUPFAILURE: wStringID=IDS_SETUPFAILURE; break;
case FNERR_SUBCLASSFAILURE: wStringID=IDS_SUBCLASSFAILURE; break;
case FNERR_BUFFERTOOSMALL: wStringID=IDS_BUFFERTOOSMALL; break;
case 0: //User may have hit CANCEL or we got a *very* random error
default:
return;
}
if (!LoadString(ghInst, wStringID, szString, sizeof(szString)))
{
ReportError(IDC_LOADSTRINGFAIL);
return;
}
MessageBox(ghWnd, szString, gszAppName, MB_OK);
return;
}
//****************************************************************************
//
// Function: ReportError(WORD)
//
// Purpose: To report an error that has occurred while allocating
// memory for the CD struct, locking the memory or while
// trying to load a resource string.
//
// Returns: void
//
// Comments:
//
// History: Date Reason
// -------- -----------------------------------
//
// 10/01/91 Created
//
//****************************************************************************
void FAR PASCAL ReportError(WORD wErrorType)
{
LPSTR lpszErrorMsg;
switch( wErrorType )
{
case IDC_ALLOCFAIL:
lpszErrorMsg=gszAllocErrorMsg;
break;
case IDC_LOCKFAIL:
lpszErrorMsg=gszLockErrorMsg;
break;
case IDC_LOADSTRINGFAIL:
lpszErrorMsg=gszLoadStrFail;
break;
default: //let's hope we never get here!
return;
}
MessageBox(ghWnd, (LPSTR)lpszErrorMsg, gszAppName, MB_OK);
return;
}