BOOL CGCColorStatic::SetHatch(const BOOL bOn, 
							   const UINT HatchType)
{
	if (m_bHatchMode == bOn) return (m_bHatchMode == bOn);

	m_bHatchMode = bOn;

	if (m_bHatchMode)
	{
		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>SetHatch() - Creating hatch brush");
		#endif

		// If the control is being set to Hatch Mode, delete the old brush
		// used for the background's ON state and create a hatch brush
		// using the same color.  

		m_brOnBrush.DeleteObject();

		m_brOnBrush.CreateHatchBrush(HatchType,m_CurrentBackgroundOnColor);

		// If the previous background OFF brush was a bitmap pattern,
		// we want to delete it and set the background OFF color to the default
		// off color.  It is expected that the client will set a color for the
		// background off color as well as for the background on color that will
		// be used for the hatch pattern.

		LOGBRUSH logicalBrush;
		m_brOffBrush.GetLogBrush(&logicalBrush);
		if ( 
				(logicalBrush.lbStyle == BS_PATTERN)
				||
				(logicalBrush.lbStyle == BS_PATTERN8X8)
		   )
		{
			m_CurrentBackgroundOffColor = DEFAULT_BACKGROUND_OFF_COLOR;
			m_brOffBrush.DeleteObject();
			m_brOffBrush.CreateSolidBrush(DEFAULT_BACKGROUND_OFF_COLOR);
		}

		m_iHatchType = HatchType;	
	}
	else
	{
		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>SetHatch() - Creating solid brush");
		#endif

		// if Hatch Mode is being turned off, then delete the hatch brush
		// and re-create the solid brush for the background's ON state.
		m_brOnBrush.DeleteObject();
		m_brOnBrush.CreateSolidBrush(m_CurrentBackgroundOnColor);
	}

	Invalidate();		// Force the control to redraw.
	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);

	return FALSE;
}
Esempio n. 2
0
void boinc_info(const char* pszFormat, ...){
    static char szBuffer[4096];
    static char szDate[64];
    static char szTime[64];
    int n;

    memset(szBuffer, 0, sizeof(szBuffer));
    memset(szDate, 0, sizeof(szDate));
    memset(szTime, 0, sizeof(szTime));

    strdate(szDate);
    strtime(szTime);

    va_list ptr;
    va_start(ptr, pszFormat);

    vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr);

    va_end(ptr);

#if defined(_WIN32) && defined(_DEBUG)
    _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer);
#else
    if (flags & BOINC_DIAG_TRACETOSTDERR) {
        n = fprintf(stderr, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer);
        if (n > 0) stderr_file_size += n;
    }

    if (flags & BOINC_DIAG_TRACETOSTDOUT) {
        n = fprintf(stdout, "[%s %s] BOINCMSG: %s\n", szDate, szTime, szBuffer);
        if (n > 0) stdout_file_size += n;
    }
#endif
}
Esempio n. 3
0
// Converts the BOINCTRACE macro into a single string and report it
//   to the CRT so it can be reported via the normal means.
//
void boinc_trace(const char *pszFormat, ...) {
    static char szBuffer[4096];
    static char szDate[64];
    static char szTime[64];
    int n;

    // Trace messages should only be reported if running as a standalone
    //   application or told too.
    if ((flags & BOINC_DIAG_TRACETOSTDERR) ||
        (flags & BOINC_DIAG_TRACETOSTDOUT)) {

        memset(szBuffer, 0, sizeof(szBuffer));
        memset(szDate, 0, sizeof(szDate));
        memset(szTime, 0, sizeof(szTime));

#ifdef _WIN32
        strdate(szDate);
        strtime(szTime);
#else
        time_t t;
        char *theCR;
    
        time(&t);
        strcpy(szTime, asctime(localtime(&t)));
        theCR = strrchr(szTime, '\n');
        if (theCR) *theCR = '\0';
        theCR = strrchr(szTime, '\r');
        if (theCR) *theCR = '\0';
#endif

        va_list ptr;
        va_start(ptr, pszFormat);

        vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr);

        va_end(ptr);

#if defined(_WIN32) && defined(_DEBUG)
        n = _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "[%s %s] TRACE [%d]: %s", szDate, szTime, GetCurrentThreadId(), szBuffer);
#else
        if (flags & BOINC_DIAG_TRACETOSTDERR) {
#ifdef _WIN32
            n = fprintf(stderr, "[%s %s] TRACE [%d]: %s\n", szDate, szTime, GetCurrentThreadId(), szBuffer);
#else
            n = fprintf(stderr, "[%s] TRACE: %s\n", szTime, szBuffer);
#endif
            if (n > 0) stderr_file_size += n;
        }

        if (flags & BOINC_DIAG_TRACETOSTDOUT) {
#ifdef _WIN32
            n = fprintf(stdout, "[%s %s] TRACE [%d]: %s\n", szDate, szTime, GetCurrentThreadId(), szBuffer);
#else
            n = fprintf(stdout, "[%s] TRACE: %s\n", szTime, szBuffer);
#endif
            if (n > 0) stdout_file_size += n;
        }
#endif
    }
}
Esempio n. 4
0
void ErrorAssert(int line, const char* file, const char* fmt, ...)
{
#if defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE)
    char msg[1024];
    va_list args;
    va_start(args, fmt);
    vsnprintf(msg, arrsize(msg), fmt, args);
#if defined(HS_DEBUGGING)
#if defined(_MSC_VER)
    if (s_GuiAsserts)
    {
        if (_CrtDbgReport(_CRT_ASSERT, file, line, NULL, msg))
            DebugBreakAlways();
    } else
#endif // _MSC_VER
    {
        DebugMsg("-------\nASSERTION FAILED:\nFile: %s   Line: %i\nMessage: %s\n-------",
                 file, line, msg);
        fflush(stderr);

        DebugBreakAlways();
    }
#endif // HS_DEBUGGING
#else
    DebugBreakIfDebuggerPresent();
#endif // defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE)
}
Esempio n. 5
0
HRESULT GenerateError (REFCLSID rClsId, REFIID riid, LPCOLESTR pcHelpFile, HRESULT hRes) {
#endif
	CComBSTR	strMsgLine;
	DWORD dwErr = FormatMessageLine( strMsgLine, hRes, NULL );
#if defined(_DEBUG)
	USES_CONVERSION;
	if( dwErr ) {
		LPTSTR lptMsg = NULL;
		CComBSTR	strMsg(L"\n---------------------- Fehler beim Erzeugen der Fehlermeldung ----------------------\n");
		if( ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwErr, 1024, (LPTSTR) &lptMsg, 0, NULL ) ) {
			USES_CONVERSION;
			strMsg.Append( A2W(lptMsg) );
			::LocalFree(lptMsg);
			if( 0x716 == dwErr ) {
				strMsg.Append(L"\n----------------------------------------------------------------------------------------");
				strMsg.Append( L"\nHat die Message-Ressource den Wert 1? ;-)" );
			}
			strMsg.Append(L"\n----------------------------------------------------------------------------------------");
			_CrtDbgReport(_CRT_ASSERT, strFile, line, NULL, W2A(strMsg) );
			return E_FAIL;
		}
	}
	CComBSTR	strDbgLine;
	FormatDebuggerLine( strDbgLine, hRes, strFile, line, strExpr );
	strDbgLine.Append( _T("\t") );
	strDbgLine.Append( strMsgLine );
	strDbgLine.Append( _T("\n") );
	{ ATLTRACE( W2A(strDbgLine) ); }
#endif
	DWORD	dwHelpID = hRes;
	return AtlReportError(rClsId, strMsgLine, dwHelpID, pcHelpFile, riid, hRes);
}
void CGCColorStatic::OnDrawFrame(WPARAM wp, LPARAM lp)
{
	if (m_bColorFrameFlag)
	{
		// Note:  I do not inflate the rectangle at which the color frame is drawn because
		// this would make the control take up more area on the screen.  If there are multiple
		// indicators next to each other, you would have the color frame of one
		// control being drawn on top of the adjoinging control.  Therefore, I paint the
		// frame inside the edges of the control.  Remember this when selecting fonts because
		// the color frame makes the area availble for displaying text a little smaller.

		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>OnDrawFrame() - Painting frame");
		#endif

		CRect rect;
		this->GetWindowRect(&rect);

		// Do not allow an exception constructing the pen or from creating
		// the device context to kill the client.
		try
		{
			CPen pen(PS_INSIDEFRAME , m_ColorFrameWidth,m_ColorFrameColor);
			ScreenToClient(&rect);
			CClientDC dc(this);
			dc.SelectObject(pen);
			dc.SelectObject(GetStockObject(NULL_BRUSH));
			dc.Rectangle(rect);
		}
		catch (CResourceException)
		{
		}
	}
}
Esempio n. 7
0
File: usUtils.cpp Progetto: 0r/MITK
void message_output(MsgType msgType, const char *buf)
{
  if (handler)
  {
    (*handler)(msgType, buf);
  }
  else
  {
    fprintf(stderr, "%s\n", buf);
    fflush(stderr);
  }

  if (msgType == ErrorMsg)
  {
  #if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
    // get the current report mode
    int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
    _CrtSetReportMode(_CRT_ERROR, reportMode);
    int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, CppMicroServices_VERSION_STR, buf);
    if (ret == 0  && reportMode & _CRTDBG_MODE_WNDW)
      return; // ignore
    else if (ret == 1)
      _CrtDbgBreak();
  #endif

  #ifdef US_PLATFORM_POSIX
    abort(); // trap; generates core dump
  #else
    exit(1); // goodbye cruel world
  #endif
  }
}
Esempio n. 8
0
BOOL  AfxAssertFailedLine(LPCSTR lpszFileName, int nLine)
{

#ifdef _ALX_USE_CRT_ASSERT

	// we remove WM_QUIT because if it is in the queue then the message box
	// won't display
	MSG msg;
	BOOL bQuit = PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
	BOOL bResult = _CrtDbgReport(_CRT_ASSERT, lpszFileName, nLine, NULL, NULL);
	if (bQuit)
		PostQuitMessage((int)msg.wParam);
	return bResult;

#else

	TCHAR szBuffer[MAX_PATH];
	if (SUCCEEDED(StringCbPrintf(szBuffer, MAX_PATH,
		_T("Assertion failed!!!\n%S (%d)\n"),
		lpszFileName, nLine)))
	{
		int nRes = MessageBox(0, szBuffer, 
			_T("ASSERTION FAILED"), MB_ABORTRETRYIGNORE|MB_ICONERROR|MB_APPLMODAL);

		if (nRes == IDABORT)
		{
			return TRUE;
		}
	}

	return FALSE;

#endif // _ALX_USE_CRT_ASSERT

}
Esempio n. 9
0
static int MyTrace(LPCTSTR lpszFormat, ...)
{
 	va_list args;
	va_start( args, lpszFormat);
#ifndef UNICODE
	char buffer[1024];
	vsprintf_s( buffer, lpszFormat, args );
	return _CrtDbgReport(_CRT_WARN,NULL,NULL,NULL,buffer);
#else
	TCHAR buffer[1024];
	vswprintf_s( buffer, lpszFormat, args );
	char fmtbuf[1024] ;
	WideCharToMultiByte(CP_ACP, 0, buffer, -1,
		fmtbuf, 1024, NULL, NULL ) ;
	return _CrtDbgReport(_CRT_WARN,NULL,NULL,NULL,fmtbuf);
#endif
}
Esempio n. 10
0
static void printCallSite(const char* file, int line, const char* function)
{
#if PLATFORM(WIN) && !PLATFORM(WINCE) && defined _DEBUG
    _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function);
#else
    printf_stderr_common("(%s:%d %s)\n", file, line, function);
#endif
}
Esempio n. 11
0
	void LDPUMA_DestroySnap()
	{
#ifdef _DEBUG
		_CrtDbgReport( _CRT_WARN,NULL,__LINE__,__FILE__,
				"LDPUMA_DestroySnap()\n");
#endif
		if(DestroySnap)
		DestroySnap();
	}
Esempio n. 12
0
int CDbgMemAlloc::CrtDbgReport( int nRptType, const char * szFile,
		int nLine, const char * szModule, const char * pMsg )
{
#ifdef WIN32	
	return _CrtDbgReport( nRptType, szFile, nLine, szModule, pMsg );
#else
	printf("XXX: CDbgMemAlloc::CrtDbgReport() not been portd to FreeBSD in file %s\n",  __FILE__);
	return 0;
#endif	
}
COLORREF CGCColorStatic::SetBackgroundOnColor(const COLORREF backColor)
{

	// Prepare to return previous background ON color.
	COLORREF prevColor = m_CurrentBackgroundOnColor;	

	// Store new background ON color.
	m_CurrentBackgroundOnColor = backColor;				

	// Calling SetBackgroundOnColor() does not change whether or not 
	// a hatch pattern is displayed.  It changes the ON color of the
	// background.  If the control is in Hatch Mode, the hatch pattern
	// will be updated with the new ON color.  If the control is NOT in
	// Hatch Mode, then the solid ON color will be updated.

	if (!m_bHatchMode)
	{
		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetBackgroundOnColor() - creating background On solid brush.");
		#endif

		// We are not in Hatch Mode.  Delete the old brush and create a new
		// SOLID brush with the new "on" color.
		m_brOnBrush.DeleteObject();	  
		m_brOnBrush.CreateSolidBrush(m_CurrentBackgroundOnColor);
	}
	else
	{
		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetBackgroundOnColor() - creating background On hatch brush.");
		#endif

		// We ARE in Hatch Mode.  Delete the old hatch brush and create a new
		// HATCH brush with the new "on" color.
		m_brOnBrush.DeleteObject();
		m_brOnBrush.CreateHatchBrush(m_iHatchType,m_CurrentBackgroundOnColor);
	}
	

	Invalidate(TRUE);					// Force to redraw.
	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);
	return prevColor;			// Return previous background ON color.
}
Esempio n. 14
0
	uint32_t LDPUMA_CreateSnap()
	{
		uint32_t rc = 0;
#ifdef _DEBUG
		_CrtDbgReport( _CRT_WARN,NULL,__LINE__,__FILE__,
				"LDPUMA_CreateSnap()\n");
#endif
		if(CreateSnap)
		rc = CreateSnap();
		return rc;
	}
Esempio n. 15
0
File: pal.c Progetto: mixtile/xskit
void xsAssert(const char *expression, const char *file, int line)
{
#ifdef _MSC_VER
#ifdef _DEBUG
	_CrtDbgReport(_CRT_ASSERT, file, line, NULL, expression);
#endif
	_CrtDbgBreak();
#else
	_assert(expression, file, line);
#endif
}
Esempio n. 16
0
static void printCallSite(const char* file, int line, const char* function)
{
#if OS(WINDOWS) && !OS(WINCE) && defined(_DEBUG)
    _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function);
#else
    // By using this format, which matches the format used by MSVC for compiler errors, developers
    // using Visual Studio can double-click the file/line number in the Output Window to have the
    // editor navigate to that line of code. It seems fine for other developers, too.
    printf_stderr_common("%s(%d) : %s\n", file, line, function);
#endif
}
void CGCColorStatic::SetColorFrame(const BOOL bOn, const int Width, const COLORREF FrameColor)
{
	m_bColorFrameFlag = bOn;

	if (!bOn)
	{
		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>SetColorFrame() - Color Frame turned on");
		#endif

		if (m_bBackgroundOn)
			m_ColorFrameColor = m_CurrentBackgroundOnColor;
		else
			m_ColorFrameColor = m_CurrentBackgroundOffColor;
	}
	else
	{
		// I made the color frame mutually exclusive of the modal and sunken frames. They just
		// do not look nice together.
		// When using the modal or sunken frames, the client area that is actually visible
		// is decreased in size.  If you were to add the color frame with the modal or sunken
		// frames, and draw the color frame so that it did not overlay the modal or sunken frame, 
		// the usable area would be even smaller.  Therefore, as a design decision,
		// I made the color frame border type mutually exclusive with the modal and sunken types.
		// Overlaying the color frame on the modal or sunken frame looks bad.

		BOOL Result = ModifyStyleEx(WS_EX_DLGMODALFRAME | WS_EX_STATICEDGE,0,SWP_DRAWFRAME);

		m_ColorFrameWidth = Width;

		#ifdef _DEBUG
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>SetColorFrame() - Color Frame turned off");
		#endif

		m_ColorFrameColor = FrameColor;
	}

	Invalidate(TRUE);					// Force to redraw.
	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);
}
Esempio n. 18
0
		void LogManager::qtMessageHandler(QtMsgType type, const char *pMessage)
		{
#else
		void LogManager::qtMessageHandler(QtMsgType type, const QMessageLogContext &, const QString & pMessage)
		{
#endif
			Level level;
			switch (type)
			{
					case QtDebugMsg:
							level = Level::DEBUG_INT;
							break;
					case QtWarningMsg:
							level = Level::WARN_INT;
							break;
					case QtCriticalMsg:
							level = Level::ERROR_INT;
							break;
					case QtFatalMsg:
							level = Level::FATAL_INT;
							break;
					default:
							level = Level::TRACE_INT;
			}
			instance()->qtLogger()->log(level, pMessage);

			// Qt fatal behaviour copied from global.cpp qt_message_output()
			// begin {

			if ((type == QtFatalMsg) ||
					((type == QtWarningMsg) && (!qgetenv("QT_FATAL_WARNINGS").isNull())) )
			{
#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
					// get the current report mode
					int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
					_CrtSetReportMode(_CRT_ERROR, reportMode);
					int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, qPrintable(pMessage));
					if (ret == 0  && reportMode & _CRTDBG_MODE_WNDW)
							return; // ignore
					else if (ret == 1)
							_CrtDbgBreak();
#endif

#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
					abort(); // trap; generates core dump
#else
					exit(1); // goodbye cruel world
#endif
			}

			// } end
	}
BOOL CGCColorStatic::SetOn(const BOOL bOn)
{

	#ifdef _DEBUG
		if (bOn)
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetOn() - Setting state to ON");
		else
			_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetOn() - Setting state to OFF");
	#endif _DEBUG

	BOOL prevState = m_bBackgroundOn;   // Key off background for overall state of control.

	m_bBackgroundOn = bOn;				// Set background to specified on/off state.
	m_bTextOn = m_bBackgroundOn;		// Sync text state to background state.

	Invalidate();

	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);


	return prevState;					// Return previous state.
}
COLORREF CGCColorStatic::SetTextOnColor(const COLORREF textColor)
{
	#ifdef _DEBUG
		_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetTextOnColor() - Setting text On color.");
	#endif

	COLORREF prevColor = m_CurrentTextOnColor;			// Prepare to return text's previous ON color.
	m_CurrentTextOnColor = textColor;					// Store text's new ON color.

	Invalidate(TRUE);								// Force edit window to repaint.
	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);
	return prevColor;
}
Esempio n. 21
0
void base_trace(const char* msg, ...)
{
  va_list ap;
  va_start(ap, msg);
  char buf[4096];
  vsprintf(buf, msg, ap);
  va_end(ap);

#ifdef _WIN32
  _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, buf);
#endif

  std::cerr << buf << std::flush;
}
Esempio n. 22
0
BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine)
{
#ifndef _AFX_NO_DEBUG_CRT
	// we remove WM_QUIT because if it is in the queue then the message box
	// won't display
//	AfxDumpStack(AFX_STACK_DUMP_TARGET_CLIPBOARD);	//** AMW added
	MSG msg;
	BOOL bQuit = PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
	BOOL bResult = _CrtDbgReport(_CRT_ASSERT, lpszFileName, nLine, NULL, NULL);
	if (bQuit)
		PostQuitMessage((int)msg.wParam);
	return bResult;
#else
	// Not supported.
#error _AFX_NO_DEBUG_CRT is not supported.
#endif // _AFX_NO_DEBUG_CRT
}
COLORREF CGCColorStatic::SetBackgroundOffColor(const COLORREF offColor)
{
	#ifdef _DEBUG
		_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">> SetBackgroundOffColor() - Creating background Off brush.");
	#endif

	COLORREF prevColor = m_CurrentBackgroundOffColor;			// Prepare to return background's previous OFF color.
	m_CurrentBackgroundOffColor = offColor;						// Store background's new OFF color.
	m_brOffBrush.DeleteObject();								// Delete background's old OFF brush.
	m_brOffBrush.CreateSolidBrush(m_CurrentBackgroundOffColor);	// Create background's new OFF brush.

	if (!m_bBackgroundOn) 
	{
		Invalidate(TRUE);					// Force to redraw.
		PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);
	}
	return prevColor;											// Return background's previous OFF color.
}
Esempio n. 24
0
	Bool32 LDPUMA_Done()
	{
		Bool32 rc = FALSE;
#ifdef _DEBUG
		_CrtDbgReport( _CRT_WARN,NULL,__LINE__,__FILE__,
				"LDPUMA_Done()\n");
		if(PrevAllocHook)
		_CrtSetAllocHook(PrevAllocHook);
#endif

		if(Done)
		rc = Done();
		if(hDPuma)
		{
			FreeLibrary(hDPuma);
			hDPuma = NULL;
		}
		return rc;
	}
Esempio n. 25
0
void nbPrintError(char *File, char *Function, int Line, char* Buffer)
{
	//	FILE *fp;
	//		fp= fopen("log.txt", "a+");
	//		fprintf(fp, "%s:%d (%s()): %s", File, Line, Function, Buffer);
	//		fclose(fp);

#ifdef _DEBUG
	fprintf(stderr, "%s:%d (%s()): %s\n", File, Line, Function, Buffer);
#else
	fprintf(stderr, "%s", Buffer);
#endif

#if (defined(_WIN32) && defined(_DEBUG))
	// _CRT_ERROR create a debug window on screen, while
	// _CRT_WARN prints the string in the output window of the Visual Studio IDE
	_CrtDbgReport(_CRT_WARN, File, Line, Function, Buffer);
#endif
}
Esempio n. 26
0
bool gep::failedAssert(const char* sourceFile, unsigned int line, const char* function, const char* expression, const char* msg, const char* additional)
{
  if(g_failedAssertHandler != nullptr)
  {
    auto handlerResult = g_failedAssertHandler->failedAssert(sourceFile, line, function, expression, msg, additional);
    if(handlerResult == AssertCallbackResult::triggerDebugBreak)
      return true; //Debug break
    else if(handlerResult == AssertCallbackResult::ignore)
      return false;
    //AssertCallbackResult::continueWithNextHandler
  }

#ifdef _DEBUG
  int userResponse = _CrtDbgReport(_CRT_ASSERT, sourceFile, line, NULL, "%s\nExpression: %s\nFunction: %s\n%s", msg, expression, function, additional);
  if(userResponse != 0)
      return true; //Debug break
#endif

  return false; //Don't debug break
}
Esempio n. 27
0
        ~AssertFunctor()
        {
            const char * msg = 
                "%s\n"
                "Values: %s\n"
                "Function: %s";

            std::string values(mArgs->str(), static_cast<std::size_t>(mArgs->tellp()));

            char szBuffer[512] = {0};
            sprintf(szBuffer, "%s(%d): Assert failed. Expression: %s.\n", mFile, mLine, mExpr);
            OutputDebugStringA(szBuffer);
            std::cout << szBuffer;
            int ret = _CrtDbgReport(_CRT_ASSERT, mFile, mLine, "", msg, mExpr, values.c_str(), mFunc);
            if (ret == 1)
            {
                // __debugbreak() is more likely to give a proper call stack.
                //DebugBreak();
                __debugbreak(); 
            }
        }
// ------------------------------------------------------------------
void msvc_debugger_listener::error(Dereferee::error_code code, va_list args)
{
	char text[513];
	vsprintf(text, error_messages[code], args);
	CxxTest::__cxxtest_assertmsg = text;

	if(debugging)
	{
		void** bt = platform->get_backtrace(NULL, NULL);
		int bufsize = vsnprintf(NULL, 0, error_messages[code], args) + 1;
		char* buffer = (char*)malloc(bufsize);
		vsnprintf(buffer, bufsize, error_messages[code], args);

		char function[DEREFEREE_MAX_FUNCTION_LEN];
		char filename[DEREFEREE_MAX_FILENAME_LEN];
		int line_number;

		void *addr = bt[4];

		bool success = platform->get_backtrace_frame_info(
			addr, function, filename, &line_number);

		platform->free_backtrace(bt);

#ifdef _DEBUG
		if(1 == _CrtDbgReport(_CRT_ERROR, filename,
			line_number, _pgmptr, buffer))
			_CrtDbgBreak();
#endif

		free(buffer);
	}

	// Can't use abort() here because it hard-kills the process on Windows,
	// rather than raising a signal that would be caught so execution could
	// continue with the next test case. Instead, cause an access violation
	// that will be caught by the structured exception handler.
	int* x = 0;
	*x = 0xBADBEEF;
}
Esempio n. 29
0
void ErrorAssert(int line, const char file[], const char fmt[], ...)
{
#if defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE)
    char msg[1024];
    va_list args;
    va_start(args, fmt);
    vsnprintf(msg, sizeof(msg), fmt, args);
#ifdef HS_DEBUGGING
    if (s_GuiAsserts)
    {
        if(_CrtDbgReport(_CRT_ASSERT, file, line, NULL, msg))
            DebugBreak();
    } else
#endif // HS_DEBUGGING
        if (DebugIsDebuggerPresent()) {
            char str[] = "-------\nASSERTION FAILED:\nFile: %s   Line: %i\nMessage: %s\n-------";
            DebugMsg(str, file, line, msg);
        }
#else
    DebugBreakIfDebuggerPresent();
#endif // defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE)
}
COLORREF CGCColorStatic::SetBackgroundOffPattern(CBitmap * pattern)
{
	#ifdef _DEBUG
		_CrtDbgReport(_CRT_WARN,"GCColorStatic.cpp",__LINE__,"Demo","\n%s\n",">>SetBackgroundOffPattern() - Creating background off pattern brush");
	#endif

	m_bHatchMode = FALSE;
	COLORREF prev = m_CurrentBackgroundOffColor;

	// Since the bitmap to be used to create the pattern brush may
	// not be a single color, just set the background "off" color to
	// the default background OFF color.
	m_CurrentBackgroundOffColor = DEFAULT_BACKGROUND_OFF_COLOR;

	m_brOffBrush.DeleteObject();				// Delete the old background "on" brush.
	m_brOffBrush.CreatePatternBrush(pattern);	// Create the new "on" pattern brush.

	Invalidate();		// Repaint the control.
	PostMessage(WM_GECCOLORSTATIC_DRAWFRAME);

	return prev;			// Return previous background OFF color.
}