static void Adjust4FillFactors(HWND hwnd) /* Function: Adjusts the maximum values of limits that are affected by the changes in fill factors. Parameters: hwnd - Handle of dialog window Returns: None. */ { INFOOFFSET infoIdx = GetSelectedStructure(hwnd); STRUCTINFO info; HLOCAL hmem = GetProp(hwnd, SZINFODEF); LPSTRUCTINFO lpinfo = LocalLock(hmem); info.nIngresVersion= GetOIVers(); GetDialogInfo(hwnd, &info); /* ** BUG #112863 : in r3 the row width can be 256K and row can span page! */ if (info.nIngresVersion < OIVERS_30) { if (info.dwPageSize == 65536L) lpinfo[infoIdx].nRowWidth = 32767L; else lpinfo[infoIdx].nRowWidth = info.dwPageSize - GetPageOverHead(info.iPageType) - GetRowOverHead(info.iPageType); } LocalUnlock(hmem); }
static void DoCalculation (HWND hwnd) { INFOOFFSET infoIdx = GetSelectedStructure(hwnd); STRUCTINFO info; DWORD dwTotalPages = 0; char szNumber[50]; // Verify all controls are within their limits. if (!VerifyAllNumericEditControls(hwnd, TRUE, TRUE)) return; info.nIngresVersion= GetOIVers(); GetDialogInfo (hwnd, &info); switch (infoIdx) { case STRUCT_HASH: dwTotalPages = CalculateHash(hwnd, &info); break; case STRUCT_ISAM: dwTotalPages = CalculateIsam(hwnd, &info); break; case STRUCT_HEAP: dwTotalPages = CalculateHeap(hwnd, &info); break; case STRUCT_BTREE: dwTotalPages = CalculateBtree(hwnd, &info); break; default: ASSERT(NULL); } if (dwTotalPages != (DWORD)-1) { // Update the results display double dBytes; my_dwtoa(dwTotalPages, szNumber, 10); Static_SetText(GetDlgItem(hwnd, IDC_INGRESPAGES), szNumber); dBytes = (double)dwTotalPages * (double)info.dwPageSize; // PS sprintf (szNumber, "%.0f", dBytes); Static_SetText(GetDlgItem(hwnd, IDC_BYTES), szNumber); } else { SetCalcError(hwnd); } }
BOOL CResModule::ExtractDialog(UINT nID) { const WORD* lpDlg; const WORD* lpDlgItem; DIALOGINFO dlg; DLGITEMINFO dlgItem; WORD bNumControls; HRSRC hrsrc; HGLOBAL hGlblDlgTemplate; hrsrc = FindResource(m_hResDll, MAKEINTRESOURCE(nID), RT_DIALOG); if (hrsrc == NULL) MYERROR; hGlblDlgTemplate = LoadResource(m_hResDll, hrsrc); if (hGlblDlgTemplate == NULL) MYERROR; lpDlg = (const WORD*) LockResource(hGlblDlgTemplate); if (lpDlg == NULL) MYERROR; lpDlgItem = (const WORD*) GetDialogInfo(lpDlg, &dlg); bNumControls = dlg.nbItems; if (dlg.caption) { TCHAR * pBuf = new TCHAR[MAX_STRING_LENGTH]; SecureZeroMemory(pBuf, MAX_STRING_LENGTH * sizeof(TCHAR)); _tcscpy(pBuf, dlg.caption); CUtils::StringExtend(pBuf); std::wstring wstr = std::wstring(pBuf); RESOURCEENTRY entry = m_StringEntries[wstr]; entry.resourceIDs.insert(nID); m_StringEntries[wstr] = entry; delete [] pBuf; } while (bNumControls-- != 0) { TCHAR szTitle[500]; SecureZeroMemory(szTitle, sizeof(szTitle)); BOOL bCode; lpDlgItem = GetControlInfo((WORD *) lpDlgItem, &dlgItem, dlg.dialogEx, &bCode); if (bCode == FALSE) _tcscpy(szTitle, dlgItem.windowName); if (_tcslen(szTitle) > 0) { CUtils::StringExtend(szTitle); std::wstring wstr = std::wstring(szTitle); RESOURCEENTRY entry = m_StringEntries[wstr]; entry.resourceIDs.insert(dlgItem.id); m_StringEntries[wstr] = entry; } } UnlockResource(hGlblDlgTemplate); FreeResource(hGlblDlgTemplate); return (TRUE); }
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. }