?? solarassert.cpp
字號:
#include "UtilityCommon.h"
#include "SolarAssert.h"
#include <string>
#pragma warning( disable:4786 )
const char * _pszAssertCaption = "Solar Assert";
const char * _pszIgnoreCaption = "Ask to Ignore Message";
const char * _pszCoypyRight = "Copyright (c) SUN Studio & Webzen.Ltd..";
const char * _pszIgnoreMessage = "撈 瘤痢狼 AssertMessageBox甫 促瀾俊檔 角青竅矯擺嚼聰鱉?";
UINT _uiAssertMessageBoxType = MB_SETFOREGROUND | MB_APPLMODAL | MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;
UINT _uiIgnoreMessageBoxType = MB_YESNO | MB_DEFBUTTON2;
char _pszVarDescription[512];
static int (APIENTRY * _pfnMessageBoxA)(HWND, LPCSTR, LPCSTR, UINT) = NULL;
static HWND (APIENTRY * _pfnGetActiveWindow)(void) = NULL;
static HWND (APIENTRY * _pfnGetLastActivePopup)(HWND) = NULL;
void _copy2Clipboard( const char * msg )
{
if( OpenClipboard( NULL ) )
{
HGLOBAL hMem = NULL;
char * pMem = 0;
hMem = GlobalAlloc( GHND | GMEM_DDESHARE, strlen( msg ) + 1 );
if( pMem )
{
pMem = (char *)GlobalLock( hMem );
strcpy( pMem, msg );
GlobalUnlock( hMem );
EmptyClipboard();
SetClipboardData( CF_TEXT, hMem );
}
CloseClipboard();
}
}
int _crtMessageBox( LPCSTR lpMsg, LPCSTR lpCaption, UINT uiType )
{
HWND hwnd = NULL;
if( NULL == _pfnMessageBoxA )
{
HANDLE hLib = LoadLibrary( "user32.dll" );
if( NULL == hLib || NULL == ( _pfnMessageBoxA = (int (APIENTRY *)(HWND, LPCSTR, LPCSTR, UINT))GetProcAddress( (HMODULE)hLib, "MessageBoxA" ) ) )
return 0;
_pfnGetActiveWindow = (HWND (APIENTRY *)(void))GetProcAddress( (HMODULE)hLib, "GetActiveWindow" ) ;
_pfnGetLastActivePopup = (HWND (APIENTRY *)(HWND))GetProcAddress( (HMODULE)hLib, "GetLastActivePopup" ) ;
}
if( _pfnGetActiveWindow )
hwnd = (*_pfnGetActiveWindow)();
if( hwnd != NULL && _pfnGetLastActivePopup )
hwnd = (*_pfnGetLastActivePopup)(hwnd);
return (*_pfnMessageBoxA)( hwnd, lpMsg, lpCaption, uiType);
}
int _ignoreMessageBox()
{
return _crtMessageBox( _pszIgnoreMessage, _pszIgnoreMessage, _uiIgnoreMessageBoxType );
}
int _solarAssertBox( const char * pszDesc, int line, char * file, char * date, char * time )
{
char tmpLineNum[16];
std::string strMsgBuf;
strMsgBuf.append( "File : " );
strMsgBuf.append( file );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "Line # : " );
strMsgBuf.append( itoa(line, tmpLineNum, 10) );
strMsgBuf.append( " line\r\n" );
strMsgBuf.append( "Description : " );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "DateTime : " );
strMsgBuf.append( date );
strMsgBuf.append( " " );
strMsgBuf.append( time );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "-----------------------------------------------------------------------" );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( pszDesc );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "\r\n" );
_copy2Clipboard( strMsgBuf.c_str() );
strMsgBuf.append( "-----------------------------------------------------------------------" );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( "[吝竄(A)] 甫 穿福擱 橇肺弊伐闌 吝竄欽聰促.\r\n" );
strMsgBuf.append( "[促矯矯檔(R)]甫 穿福擱 Assert 瘤痢欄肺 撈悼欽聰促.\r\n" );
strMsgBuf.append( "[公矯(I)] 甫 穿福擱 橇肺弊伐闌 拌加 柳青欽聰促.\r\n" );
strMsgBuf.append( "-----------------------------------------------------------------------" );
strMsgBuf.append( "\r\n" );
strMsgBuf.append( _pszCoypyRight );
strMsgBuf.append( "\r\n" );
int rt = _crtMessageBox( strMsgBuf.c_str(), _pszAssertCaption, _uiAssertMessageBoxType );
if( rt == IDABORT )
{
exit(9);// return 1;
}
if( rt == IDRETRY )
{
return 2;
}
if( rt == IDIGNORE )
{
return 3;
}
return 0;
}
char * VSTR( char * s, ...)
{
va_list arg;
va_start( arg, s );
vsprintf( _pszVarDescription, s, arg );
va_end( arg );
return _pszVarDescription;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -