Remove builtin support for GUI warning and error message boxes

Now warnings always go to the console by default unless applications
define their own warning and error handlers.

GUI applications (and Windows CE) are required to define such handlers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-02-26 11:34:14 +01:00
parent 58a898cb44
commit 924405d5b3
3 changed files with 0 additions and 56 deletions

View File

@ -405,60 +405,21 @@ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
static void
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
{
#ifndef TIF_PLATFORM_CONSOLE
LPTSTR szTitle;
LPTSTR szTmp;
LPCTSTR szTitleText = "%s Warning";
LPCTSTR szDefaultModule = "LIBTIFF";
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
SIZE_T nBufSize = (strlen(szTmpModule) +
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
return;
sprintf(szTitle, szTitleText, szTmpModule);
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
LocalFree(szTitle);
return;
#else
if (module != NULL)
fprintf(stderr, "%s: ", module);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
#endif
}
TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;
static void
Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
{
#ifndef TIF_PLATFORM_CONSOLE
LPTSTR szTitle;
LPTSTR szTmp;
LPCTSTR szTitleText = "%s Error";
LPCTSTR szDefaultModule = "LIBTIFF";
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
SIZE_T nBufSize = (strlen(szTmpModule) +
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
return;
sprintf(szTitle, szTitleText, szTmpModule);
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
LocalFree(szTitle);
return;
#else
if (module != NULL)
fprintf(stderr, "%s: ", module);
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
#endif
}
TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;

View File

@ -34,9 +34,6 @@
#include "tiffiop.h"
#include <windows.h>
/* Turn off console support on Windows CE. */
#undef TIF_PLATFORM_CONSOLE
COMPILATION SHOULD FAIL
This file is not yet updated to reflect changes in LibTiff 4.0. If you have
the opportunity to update and test this file, please contact LibTiff folks

View File

@ -34,13 +34,6 @@
###### Edit the following lines to choose a feature set you need. #######
#
#
# Select WINMODE_CONSOLE to build a library which reports errors to stderr, or
# WINMODE_WINDOWED to build such that errors are reported via MessageBox().
#
WINMODE_CONSOLE = 1
#WINMODE_WINDOWED = 1
#
# Comment out the following lines to disable internal codecs.
#
@ -159,13 +152,6 @@ DLLNAME = libtiff.dll
# Set the native cpu bit order
EXTRAFLAGS = -DFILLODER_LSB2MSB $(EXTRAFLAGS)
!IFDEF WINMODE_WINDOWED
EXTRAFLAGS = -DTIF_PLATFORM_WINDOWED $(EXTRAFLAGS)
LIBS = user32.lib $(LIBS)
!ELSE
EXTRAFLAGS = -DTIF_PLATFORM_CONSOLE $(EXTRAFLAGS)
!ENDIF
# Codec stuff
!IFDEF CCITT_SUPPORT
EXTRAFLAGS = -DCCITT_SUPPORT $(EXTRAFLAGS)