ImageGear for C and C++ on Windows v20.1 - Updated
IG_warning_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Warning Functions > IG_warning_get

This function retrieves an ImageGear warning Code and associated information from the error stack.

Declaration:

 
Copy Code
VOID ACCUAPI IG_warning_get(
   INT iErrorIndex,
   LPSTR szFileName,
   INT cbFileNameSize,
   LPINT lpiLineNumber,
   LPAT_ERRCODE lpiCode,
   LPAT_INT lplValue1,
   LPAT_INT lplValue2,
   LPSTR pszWarning,
   INT nWarningSize
);

Arguments:

Name Type Description
iErrorIndex INT Tells which warning to fetch from stack. A value of 0 means fetch the first warning placed on the stack.
szFileName LPSTR Pointer indicating where to return the module name in which this error occurred. If this pointer is NULL, the module name is not returned.
cbFileNameSize INT Number of bytes available in byte array pointed to by szFileName.
lpiLineNumber LPINT Pointer indicating where to return the line number at which the warning occurred. If NULL, the line number is not returned.
lpiCode LPAT_ERRCODE Pointer indicating where to return the Warning Code. If NULL, the Warning Code is not returned.
lplValue1 LPAT_INT Pointer indicating where to return a value stored as lValue1 when the warning occurred. If NULL, this value is not returned. See Remarks below for explanation of lValue1 and lValue2.
lplValue2 LPAT_INT Pointer indicating where to return a value stored as lValue2 when the warning occurred. If NULL, this value is not returned. See Remarks below for explanation of lValue1 and lValue2.
pszWarning LPSTR Pointer indicating where to return additional text description.
nWarningSize INT Size of the memory buffer pszWarning.

Return Value:

None

Supported Raster Image Formats:

This function does not process image pixels.

Sample:

None

Example:

 
Copy Code
INT i;                        // Will hold Loop Index and Error Index
INT iLineNumber;            // Will hold returned Line Number
BYTE szFileName[30];        // Will hold ret'd module name, up to 29 chars
INT cbFileNameSize;            // Will hold size of szFileName array
AT_INT lValue1, lValue2;    // Will hold returned lValue1, lValue2
AT_ERRCODE iWarnCode;        // Will hold returned warning code
CHAR szWaringMessage[256];    // Will hold returned warning message
AT_ERRCOUNT nWarnCount;        // Will hold count of errors on error stack  
TCHAR szBuf[60];            // Will hold zero-terminated string returned by wsprintf() below
cbFileNameSize = 30;        // Size of module-name array
nWarnCount = IG_warning_check(); // Get number of errors on stack
for ( i = 0;  i < nWarnCount;  i++ )
{
    // Get Module Name, Line Number, Error Code, and lValue1, lValue2:
    IG_warning_get ( i, (LPSTR) &szFileName, 
            cbFileNameSize, &iLineNumber, (LPAT_ERRCODE)&iWarnCode, 
            (LPAT_INT) &lValue1, (LPAT_INT) &lValue2,
            szWaringMessage, sizeof(szWaringMessage));
    // Format warning message in szBuf:
    wsprintf ( szBuf, _T("Warning %d in Module %s at Line %d"), iWarnCode, szFileName, iLineNumber );
    // Display warning message in a Message Box, with heading "Warning" : 
    MessageBox ( NULL, szBuf, _T("Warning"), MB_OK );
}
IG_warning_clear(); // Done getting errors, clear the error stack

Remarks:

Set iErrorIndex to indicate which warning to get. iErrorIndex = 0 means the warning added to the stack first. The other arguments (except cbFileNameSize) are pointers telling this function where to return the retrieved information to you. This information consists of the Warning Code, the module name and line number at which the error occurred, and two additional values (lValue1 and lValue2) that may provide additional information about the warning and a buffer for the additional text information. A size of the buffer is passed in the last parameter. See the Function Error Return Codes Appendix for a list of all ImageGear Error Codes and the significance of lValue1, lValue2 where applicable.

To determine the number of warnings currently on the error stack use IG_warning_check. After fetching all error information you need using IG_warning_get, use IG_warning_clear to clear the stack.

A call to this function has the same effect as a call to IG_err_error_get with nLevel equal to 1. If the user has defined his own warning levels (greater than 1), he should use IG_err_error_get function instead.

Is this page helpful?
Yes No
Thanks for your feedback.