void CDECL Error::TraceUser(const char *User, LPCTSTR fmt, ...) { if (!IsUserName(User)) return; va_list marker; va_start( marker, fmt ); // wxVLogDebug(fmt, marker); TraceWrite(fmt, marker); va_end( marker ); }
void OpGenericDownload::OnDownloadAbort() { // get a pointer to the OpParam so that I can retrieve some useful information GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam; String_256 GenericFile = pGenericParam->strURL; if (IsUserName("Olivier")) TRACE1("OpGenericDownload::OnDownloadAbort(), file = %s\n", (TCHAR*)GenericFile); // stop the import op SelOperation* Op = pGenericParam->m_Op; ((OpMenuImport*)Op)->EndImport(); }
void OpGenericDownload::OnDownloadSuccess() { // get a pointer to the OpParam so that I can retrieve some useful information GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam; String_256 GenericFile = (pGenericParam->file).GetFileName(); if (IsUserName("Olivier")) TRACE1("OpGenericDownload::OnDownloadSuccess(), file = %s\n", (TCHAR*)GenericFile); Filter* pFilter = pGenericParam->m_pFilter; PathName Path = pGenericParam->file; String_256 URL = pGenericParam->strURL; SelOperation* Op = pGenericParam->m_Op; // call the DoImport function from OpMenuImport class ((OpMenuImport*)Op)->DoImport(Path, pFilter, &URL); // remove the temporary file remove((TCHAR*) (String_256) Path.GetPath()); }
BOOL GRenderWinG::Init( BOOL FirstTime ) { if (!FirstTime) { // only a screen mode change so don't redo DLL etc, just get new DC if (WinGDLL) { // kill old one if (OffScreenDC) DeleteDC( OffScreenDC ); // go get new one OffScreenDC = pWinGCreateDC(); if (OffScreenDC) return TRUE; } return FALSE; } #if WIN32 // lets see if the DLL is there // on NT 3.1 the DLL init code fails the load and produces an ugly dialog, so we don't // bother if (IsWin32NT()) { const WORD Ver = LOWORD( GetVersion() ); if ( (LOBYTE(Ver) == 3) && // NT 3.5 is minimum requirement (HIBYTE(Ver) < 50) ) return FALSE; } // try the DLL now WinGDLL = LoadLibrary("WING32.DLL"); if (WinGDLL) { // (ordinal values extracted from DLL using DUMPBIN -export) pWinGCreateDC = (WING_CREATEDC) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3e9) ); pWinGCreateBitmap = (WING_CREATEBITMAP) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3eb) ); pWinGBitBlt = (WING_BITBLT) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3f2) ); pWinGRecommendedDIBFormat = (WING_RECOMMENDED) GetProcAddress( WinGDLL, MAKEINTRESOURCE( 0x3ea ) ); if ( (pWinGCreateDC == NULL) || (pWinGCreateBitmap == NULL) || (pWinGBitBlt == NULL) || (pWinGRecommendedDIBFormat==NULL) ) { TRACE( _T("WinG32 DLL entrypoints missing!\n")); FreeLibrary( WinGDLL ); WinGDLL = NULL; return FALSE; } } else { TRACE( _T("WinG DLL not found (error %d)\n"), GetLastError() ); return FALSE; } // remember the DLL handle so it gets cleaned up for us always on exit ExtraDLLs[ WinG_DLL ] = WinGDLL; RecommendedDIB.biSize = sizeof(BITMAPINFOHEADER); // excuse the seemingly rampant cast but I think the official prototype is wrong const BOOL ok = pWinGRecommendedDIBFormat( (LPBITMAPINFO)&RecommendedDIB ); if (IsUserName("Andy")) { TRACE( _T("Recommended bitmap:\n")); if (ok) { TRACE( _T("%dx%d height=%d comp=%d\n"), (INT32)RecommendedDIB.biPlanes, (INT32)RecommendedDIB.biBitCount, (INT32)RecommendedDIB.biHeight, (INT32)RecommendedDIB.biCompression ); } else TRACE( _T("ERROR - isnt one\n")); } OffScreenDC = pWinGCreateDC(); if (OffScreenDC) return TRUE; #endif // if we get here it means we failed return FALSE; }
BOOL CInformErrorDialog::OnInitDialog() { CDialog::OnInitDialog(); String_64 BoxTitle; BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR); // "Serious error" String_256 VerySeriousError; VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR); // "A very serious error has occured - please consult your technical support." // Andy Hills, 22-11-00 // Store the help context. // We need to do this here, because the global help context variable // nNextMessageHelpContext may change before the user clicks the 'Help' // button. This fixes bug 6359. m_nHelpContext = Error::GetErrorNumber(); if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext(); // Find out how many buttons there are. for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--) { if (m_ButtonStr[NumButtons - 1] != 0) break; } // Adjust the OK and Cancel fields if necessary if (m_OK > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("OK out of range, OK=%u, NumButtons=%d\n"), m_OK, NumButtons); } // Default to first button m_OK = 1; } if (m_Cancel > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d\n"), m_Cancel, NumButtons); } // Default to be the same as OK (this means a box with a single OK box will // respond to Enter and Esc without the user having to specify a Cancel ID). m_Cancel = m_OK; } if (m_Help > (UINT32) NumButtons) { TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)\n"), (INT32) m_Help, (INT32) NumButtons); // The only really safe thing we can do is drop the help button. m_Help = 0; } // Make sure we have correct dialog information GetDialogInfo(); if (!ValidInfo) { // Serious error - fall back to to MessageBox(). goto SevereError; } // Get icon position IconPos = DefIconPos; // Get a DC for this dialog, so we can find out the size of text strings. // We'll also need to select in our font or else it'll base the width upon the // System font rather than the font we're using (MS Sans Serif at last check) CDC *pDC; CFont *OldFont; pDC = GetDC(); ENSURE(pDC != NULL, "Can't get DC for error box dialog"); // Check the DC if (pDC == NULL) goto SevereError; OldFont = pDC->SelectObject(GetFont()); // Set buttons text and move/resize buttons according to the number of them, // and their contents. BOOL Success; Success = SetupButtons(pDC->m_hDC, NumButtons); // Size the error message control, and put the message in it. Success = Success && SetupMessage(pDC->m_hDC); if (OldFont != NULL) pDC->SelectObject(OldFont); // We've finished with this DC now. ReleaseDC(pDC); // Check for failure in button/message setup. if (!Success) goto SevereError; // Play the appropriate sound and set the appropriate title bar text ID. UINT32 TitleID; TitleID = m_TitleStr; switch (m_ErrorBoxType) { case ERRORTYPE_NORMAL: // No sound for this one - it's just a message; nothing to shout about. if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_QUESTION: MessageBeep(MB_ICONQUESTION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_ERROR: MessageBeep(MB_ICONEXCLAMATION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ERROR); break; case ERRORTYPE_WARNING: MessageBeep(MB_ICONASTERISK); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_WARNING); break; case ERRORTYPE_SERIOUS: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_SERIOUS); break; case ERRORTYPE_ENSURE: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ENSURE); break; default: ENSURE(FALSE, "Bad errortype in CInformErrorDialog::OnInitDialog()"); goto SevereError; break; } // Set the title bar text if necessary. if (TitleID != 0) { String_64 Title(TitleID); SetWindowText((TCHAR*) Title); } // Centre the dialog on the screen (Code stolen from splash.cpp) // Get the size of the screen INT32 ScreenWidth, ScreenHeight; ScreenWidth = GetSystemMetrics(SM_CXSCREEN); ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Get the size of the dialog box RECT DialogRect; GetWindowRect(&DialogRect); INT32 DialogWidth, DialogHeight; DialogWidth = DialogRect.right - DialogRect.left; DialogHeight = DialogRect.bottom - DialogRect.top; // Chicago M7 gives us crap values at this point if we are minimized so try and make them sane if (DialogWidth<=0) DialogWidth = ScreenWidth / 2; else if (DialogWidth > ScreenWidth) DialogWidth = ScreenWidth; if (DialogHeight<=0) DialogHeight = ScreenHeight / 2; else if (DialogHeight > ScreenHeight) DialogHeight = ScreenHeight; // Centre the dialog box and give it the 'top' style. INT32 Left, Top; Left = (ScreenWidth - DialogWidth) / 2; Top = (ScreenHeight - DialogHeight) / 2; SetWindowPos(&wndTop, Left, Top, DialogWidth, DialogHeight, SWP_SHOWWINDOW); // If we got this far, then we changed the keyboard focus, so return FALSE. return FALSE; SevereError: // Ooer - deeply catastrophic error...report to user and exit. String_256 Message; // First - check that this isn't just because of an empty error message. if (m_StaticTextStr == 0) { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if ((pMsg == NULL) || (pMsg[0] == 0)) { // // There is no error message! // // In debug builds, give developer a chance to go into debugger to see who is not // setting an error message. #ifdef _DEBUG if (::MessageBox(ParentHwnd, "Somebody reported an error without an error message being set.\r" "Click OK to continue, or Cancel to go into debugger", "DEBUG Warning from Camelot", MB_OKCANCEL| MB_SYSTEMMODAL | MB_ICONHAND) == IDCANCEL) { // User wants to go into debugger DebugBreak(); } #endif // Tell the user a spurious error has occured, if (!Message.Load(_R(IDS_ERRORBOX_SPURIOUS))) // Can't load error message - panic. goto VerySevereError; // Try to get the string that says "Warning from Camelot" String_64 Title; if (!Title.Load(_R(IDS_ERRORBOX_WARNING))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *) Title, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. } } // Inform the user that we've got a bit of a bad karma situation, and that the error // box might be not be completely accurate. if (!Message.Load(_R(IDS_ERRORBOX_SEVERE))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, /*"Serious Error", */ MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Ok - try to report the error as best we can... // Work out what buttons to put on the dialog... // We use SYSTEMMODAL with ICONHAND because the SDK docs recommend this for low // memory/severe error situations. UINT32 MBFlags; MBFlags = MB_SYSTEMMODAL | MB_ICONHAND; // Do we need a cancel icon? if (m_Cancel != m_OK) MBFlags |= MB_OKCANCEL; else MBFlags |= MB_OK; if (m_StaticTextStr != 0) { if (Message.Load(m_StaticTextStr, m_OwnerModule)) { // Error message loaded ok - display it INT32 Result = ::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } else { // Can't load error message - bail out goto VerySevereError; } } else { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if (pMsg == NULL) // No error message! goto VerySevereError; // Found error message ok - display it INT32 Result = ::MessageBox(ParentHwnd, pMsg, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } VerySevereError: // Very bad - we can't even report the error - just let the user that something deeply // sad has happened, and pretend that the OK button was pressed. ::MessageBox(ParentHwnd, (TCHAR *)VerySeriousError, (TCHAR *)BoxTitle, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND); // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. }