00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104
00105 #include "errorbox.h"
00106
00107
00108
00109
00110 #include "splash.h"
00111 #include "mainfrm.h"
00112
00113 #include "prdlgctl.h"
00114
00115 #include "helpuser.h"
00116
00117
00118 CInformErrorDialog::CInformErrorDialog(CWnd* pParent )
00119 : CDialog(CInformErrorDialog::IDD, pParent ? pParent : GetSafeParent() )
00120 {
00121
00122
00123
00124
00125
00126 ParentHwnd = GetSafeParent()->GetSafeHwnd();
00127
00128
00129 m_StaticTextStr = 0;
00130 m_TitleStr = 0;
00131 m_ErrorBoxType = ERRORTYPE_ERROR;
00132 m_OwnerModule = 0L;
00133 m_OK = 1;
00134 m_Cancel = 2;
00135 m_Help = 0;
00136
00137
00138 m_ButtonStr[0] = _R(IDS_OK);
00139 for (INT32 i = 1; i < ERRORDLG_MAXBUTTONS; i++) m_ButtonStr[i] = 0;
00140 }
00141
00142
00143
00144 void CInformErrorDialog::DoDataExchange(CDataExchange* pDX)
00145 {
00146
00147 CDialog::DoDataExchange(pDX);
00148
00149 DDX_Control(pDX, _R(ID_ERRORBOX_BUTTON5), m_Button[4]);
00150 DDX_Control(pDX, _R(ID_ERRORBOX_BUTTON4), m_Button[3]);
00151 DDX_Control(pDX, _R(ID_ERRORBOX_BUTTON3), m_Button[2]);
00152 DDX_Control(pDX, _R(ID_ERRORBOX_BUTTON2), m_Button[1]);
00153 DDX_Control(pDX, _R(ID_ERRORBOX_BUTTON1), m_Button[0]);
00154
00155 }
00156
00157
00158
00159 BEGIN_MESSAGE_MAP(CInformErrorDialog, CDialog)
00160
00161 ON_WM_PAINT()
00162 ON_BN_CLICKED(_R(ID_ERRORBOX_BUTTON1), OnClickedButton1)
00163 ON_BN_CLICKED(_R(ID_ERRORBOX_BUTTON2), OnClickedButton2)
00164 ON_BN_CLICKED(_R(ID_ERRORBOX_BUTTON3), OnClickedButton3)
00165 ON_BN_CLICKED(_R(ID_ERRORBOX_BUTTON4), OnClickedButton4)
00166 ON_BN_CLICKED(_R(ID_ERRORBOX_BUTTON5), OnClickedButton5)
00167 ON_COMMAND(IDCANCEL, OnCancelCmd)
00168
00169 END_MESSAGE_MAP()
00170
00171
00172
00173 SIZE CInformErrorDialog::DefButtonSize;
00174 INT32 CInformErrorDialog::ButtonSpacing;
00175 SIZE CInformErrorDialog::DialogSize;
00176 INT32 CInformErrorDialog::EdgeSpacing;
00177 INT32 CInformErrorDialog::DefTopOfButton;
00178 POINT CInformErrorDialog::DefIconPos;
00179 SIZE CInformErrorDialog::DefMsgSize;
00180 BOOL CInformErrorDialog::ValidInfo = FALSE;
00181 String_64 CInformErrorDialog::ButtonText[ERRORDLG_MAXBUTTONS];
00182
00183
00184
00185
00186 UINT32 CInformErrorDialog::ButtonID[ERRORDLG_MAXBUTTONS] =
00187 {
00188 _R(ID_ERRORBOX_BUTTON1),
00189 _R(ID_ERRORBOX_BUTTON2),
00190 _R(ID_ERRORBOX_BUTTON3),
00191 _R(ID_ERRORBOX_BUTTON4),
00192 _R(ID_ERRORBOX_BUTTON5)
00193 };
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 void CInformErrorDialog::GetDialogInfo()
00212 {
00213
00214 if (ValidInfo)
00215 return;
00216
00217
00218 CRect DlgRect;
00219 GetClientRect(&DlgRect);
00220 DialogSize.cx = DlgRect.Width();
00221 DialogSize.cy = DlgRect.Height();
00222
00223
00224 CWnd *pCtrl1 = GetDlgItem(ButtonID[0]);
00225 CWnd *pCtrl2 = GetDlgItem(ButtonID[1]);
00226 ENSURE((pCtrl1 != NULL) && (pCtrl2 != NULL),
00227 "Can't find control in CInformErrorDialog::OnInitDialog()");
00228
00229
00230 if ((pCtrl1 == NULL) || (pCtrl2 == NULL))
00231 return;
00232
00233
00234 WINDOWPLACEMENT Placement;
00235 Placement.length = sizeof(WINDOWPLACEMENT);
00236 pCtrl1->GetWindowPlacement(&Placement);
00237
00238 DefTopOfButton = Placement.rcNormalPosition.top;
00239 DefButtonSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
00240 DefButtonSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;
00241 EdgeSpacing = Placement.rcNormalPosition.left;
00242
00243
00244 Placement.length = sizeof(WINDOWPLACEMENT);
00245 pCtrl2->GetWindowPlacement(&Placement);
00246
00247 ButtonSpacing = Placement.rcNormalPosition.left - (EdgeSpacing + DefButtonSize.cx);
00248
00249
00250 CWnd *pIconCtrl = GetDlgItem(_R(IDC_ERRORBOX_ICON));
00251 ENSURE(pIconCtrl != NULL, "Can't find Icon control in CInformErrorDialog::GetDialogInfo()");
00252
00253
00254 if (pIconCtrl == NULL)
00255 return;
00256
00257 Placement.length = sizeof(WINDOWPLACEMENT);
00258 pIconCtrl->GetWindowPlacement(&Placement);
00259
00260 DefIconPos.x = Placement.rcNormalPosition.left;
00261 DefIconPos.y = Placement.rcNormalPosition.top;
00262
00263
00264 CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));
00265 ENSURE(pMsgCtrl != NULL, "Can't find Text control in CInformErrorDialog::GetDialogInfo()");
00266
00267
00268 if (pMsgCtrl == NULL)
00269 return;
00270
00271 Placement.length = sizeof(WINDOWPLACEMENT);
00272 pMsgCtrl->GetWindowPlacement(&Placement);
00273
00274 DefMsgSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
00275 DefMsgSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;
00276
00277
00278 ValidInfo = TRUE;
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 BOOL CInformErrorDialog::SetupButtons(HDC hDC, INT32 NumButtons)
00304 {
00305
00306 CWnd *pDefCtrl = GetDlgItem(ButtonID[m_OK - 1]);
00307 ENSURE(pDefCtrl != NULL, "Can't get handle to default control in CInformErrorDialog");
00308
00309
00310 if (pDefCtrl == NULL)
00311 {
00312 ENSURE(FALSE, "Can't get default button in error box!");
00313 return FALSE;
00314 }
00315
00316
00317 pDefCtrl->SetFocus();
00318 SendMessage(DM_SETDEFID, ButtonID[m_OK - 1], 0);
00319
00320
00321 INT32 ButtonWidth = DefButtonSize.cx;
00322 INT32 i;
00323 for (i = 0; i < NumButtons; i++)
00324 {
00325
00326 if (!ButtonText[i].Load(m_ButtonStr[i], m_OwnerModule))
00327 {
00328 ENSURE(FALSE, "Unable to load button text for error box!");
00329 return FALSE;
00330 }
00331
00332
00333 SIZE TextSize;
00334 if (!GetTextExtentPoint(hDC, (TCHAR *) ButtonText[i], ButtonText[i].Length(),
00335 &TextSize))
00336 {
00337
00338 ENSURE(FALSE, "Unable to read button text size for error box!");
00339 return FALSE;
00340 }
00341
00342 if (TextSize.cx > ButtonWidth)
00343 ButtonWidth = TextSize.cx + 8;
00344 }
00345
00346
00347 ButtonWidth += 8;
00348
00349
00350 INT32 MaxWidth = DialogSize.cx -
00351 (2 * EdgeSpacing) -
00352 ((NumButtons - 1) * ButtonSpacing);
00353
00354
00355 if (NumButtons == 0)
00356 {
00357 ENSURE(FALSE, "NumButtons is zero in error box!");
00358 return FALSE;
00359 }
00360
00361
00362 MaxWidth /= NumButtons;
00363
00364
00365 INT32 NewWidth = DialogSize.cx;
00366
00367
00368 if (ButtonWidth > MaxWidth)
00369 {
00370
00371
00372
00373
00374 NewWidth = (EdgeSpacing * 2) +
00375 (NumButtons * ButtonWidth) +
00376 ((NumButtons - 1) * ButtonSpacing);
00377
00378
00379 INT32 ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
00380
00381 if (ScreenWidth < NewWidth)
00382 {
00383
00384 ButtonWidth = ScreenWidth -
00385 (2 * EdgeSpacing) -
00386 ((NumButtons - 1) * ButtonSpacing);
00387 ButtonWidth /= NumButtons;
00388
00389 NewWidth = ScreenWidth;
00390 }
00391
00392
00393 SIZE BorderSize;
00394 BorderSize.cx = 2 * ::GetSystemMetrics(SM_CXDLGFRAME);
00395 BorderSize.cy = ::GetSystemMetrics(SM_CYDLGFRAME) +
00396 ::GetSystemMetrics(SM_CYCAPTION);
00397
00398 if (!SetWindowPos(NULL, 0, 0,
00399 NewWidth + BorderSize.cx, DialogSize.cy + BorderSize.cy,
00400 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW))
00401 {
00402 ENSURE(FALSE, "Unable to resize the error box!");
00403 return FALSE;
00404 }
00405
00406
00407 INT32 Diff = NewWidth - DialogSize.cx;
00408
00409 CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));
00410 ENSURE(pMsgCtrl != NULL, "Can't get handle to text control in CInformErrorDialog");
00411
00412 if (pMsgCtrl != NULL)
00413 {
00414
00415 if (!pMsgCtrl->SetWindowPos(NULL, 0, 0,
00416 DefMsgSize.cx + Diff, DefMsgSize.cy,
00417 SWP_NOACTIVATE | SWP_NOZORDER |
00418 SWP_NOMOVE | SWP_NOREDRAW))
00419 {
00420 ENSURE(FALSE, "Unable to adjust error message control in error box!");
00421 return FALSE;
00422 }
00423 }
00424 }
00425
00426
00427
00428
00429 INT32 SpareSpace = NewWidth -
00430 (NumButtons * ButtonWidth) -
00431 ((NumButtons - 1) * ButtonSpacing);
00432
00433
00434 INT32 FarLeft = SpareSpace / 2;
00435
00436 INT32 ButtonStep = ButtonSpacing + ButtonWidth;
00437
00438
00439
00440
00441
00442 for (i = 0; i < NumButtons; i++)
00443 {
00444 SetDlgItemText(ButtonID[i], ButtonText[i]);
00445
00446 if (!m_Button[i].SetWindowPos(NULL,
00447 FarLeft + (i * ButtonStep), DefTopOfButton,
00448 ButtonWidth, DefButtonSize.cy,
00449 SWP_NOACTIVATE | SWP_NOZORDER |
00450 SWP_NOREDRAW | SWP_SHOWWINDOW))
00451 {
00452 ENSURE(FALSE, "Unable to move button in the error box!");
00453 return FALSE;
00454 }
00455 }
00456
00457
00458 return TRUE;
00459 }
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 BOOL CInformErrorDialog::SetupMessage(HDC hDC)
00480 {
00481
00482 SIZE TextSize;
00483 RECT TextRect;
00484 INT32 Offset = 0;
00485
00486 CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));
00487 ENSURE(pMsgCtrl != NULL, "Can't get handle to text control in CInformErrorDialog");
00488
00489
00490 if (pMsgCtrl == NULL)
00491 {
00492
00493 ENSURE(FALSE, "Unable to access error message control");
00494 return FALSE;
00495 }
00496
00497
00498 RECT MsgCtrlRect;
00499 pMsgCtrl->GetWindowRect(&MsgCtrlRect);
00500 ScreenToClient(&MsgCtrlRect);
00501
00502
00503
00504 TextRect = MsgCtrlRect;
00505
00506 if (m_StaticTextStr != 0)
00507 {
00508 String_256 MsgStr(m_StaticTextStr, m_OwnerModule);
00509 SetDlgItemText(_R(IDC_ERRORBOX_TEXT), MsgStr);
00510 DrawText(hDC, (TCHAR *) MsgStr, -1, &TextRect, DT_CALCRECT | DT_TOP | DT_LEFT | DT_WORDBREAK);
00511 }
00512 else
00513 {
00514 TCHAR *pMsg = Error::GetErrorString();
00515 SetDlgItemText(_R(IDC_ERRORBOX_TEXT), pMsg);
00516 DrawText(hDC, pMsg, -1, &TextRect, DT_CALCRECT | DT_TOP | DT_LEFT | DT_WORDBREAK);
00517 }
00518
00519 TextSize.cx = TextRect.right - TextRect.left;
00520 TextSize.cy = TextRect.bottom - TextRect.top;
00521
00522 if ((TextSize.cx == 0) || (TextSize.cy == 0))
00523 {
00524
00525 ENSURE(FALSE, "Unable to read size of error message");
00526 return FALSE;
00527 }
00528
00529
00530 SIZE MsgCtrlSize;
00531 MsgCtrlSize.cx = MsgCtrlRect.right - MsgCtrlRect.left;
00532 MsgCtrlSize.cy = MsgCtrlRect.bottom - MsgCtrlRect.top;
00533
00534 if ((MsgCtrlSize.cx == 0) || (MsgCtrlSize.cy == 0))
00535 {
00536
00537 ENSURE(FALSE, "Bad message control size in error dialog box!");
00538 return FALSE;
00539 }
00540
00541
00542
00543 if (MsgCtrlSize.cx < TextSize.cx || MsgCtrlSize.cy < TextSize.cy)
00544 {
00545 if (MsgCtrlSize.cx < TextSize.cx)
00546 MsgCtrlSize.cx = TextSize.cx + 8;
00547
00548 if (MsgCtrlSize.cy < TextSize.cy)
00549 {
00550 Offset = TextSize.cy - MsgCtrlSize.cy + 8;
00551 MsgCtrlSize.cy = TextSize.cy + 8;
00552 }
00553
00554
00555 if (!pMsgCtrl->SetWindowPos(NULL, 0, 0, MsgCtrlSize.cx, MsgCtrlSize.cy,
00556 SWP_NOACTIVATE | SWP_NOZORDER |
00557 SWP_NOMOVE | SWP_NOREDRAW))
00558 {
00559 ENSURE(FALSE, "Unable to resize the message control in error box!");
00560 return FALSE;
00561 }
00562
00563
00564 IconPos.y += (Offset / 2);
00565
00566
00567 for (INT32 i = 0; i < ERRORDLG_MAXBUTTONS; i++)
00568 {
00569 RECT ButtonRect;
00570 m_Button[i].GetWindowRect(&ButtonRect);
00571 ScreenToClient(&ButtonRect);
00572 if (!m_Button[i].SetWindowPos(NULL, ButtonRect.left, ButtonRect.top + Offset,
00573 0, 0,
00574 SWP_NOACTIVATE | SWP_NOZORDER |
00575 SWP_NOSIZE | SWP_NOREDRAW))
00576 {
00577 ENSURE(FALSE, "Unable to resize the button control in error box!");
00578 return FALSE;
00579 }
00580 }
00581
00582
00583 RECT DialogRect;
00584 GetWindowRect(&DialogRect);
00585 INT32 DialogWidth = DialogRect.right - DialogRect.left;
00586 INT32 DialogHeight = DialogRect.bottom - DialogRect.top;
00587
00588 if (!SetWindowPos(NULL, 0, 0, DialogWidth, DialogHeight + Offset,
00589 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW))
00590 {
00591 ENSURE(FALSE, "Unable to resize the error box dialog!");
00592 return FALSE;
00593 }
00594 }
00595
00596
00597 return TRUE;
00598 }
00599
00600
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618 BOOL CInformErrorDialog::OnInitDialog()
00619 {
00620 CDialog::OnInitDialog();
00621
00622 String_64 BoxTitle;
00623 BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR);
00624
00625 String_256 VerySeriousError;
00626 VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR);
00627
00628
00629
00630
00631
00632
00633 m_nHelpContext = Error::GetErrorNumber();
00634 if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext();
00635
00636
00637 for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--)
00638 {
00639 if (m_ButtonStr[NumButtons - 1] != 0) break;
00640 }
00641
00642
00643 if (m_OK > (UINT32) NumButtons)
00644 {
00645 if (IsUserName("Tim"))
00646 {
00647 TRACE( _T("OK out of range, OK=%u, NumButtons=%d\n"), m_OK, NumButtons);
00648 }
00649
00650 m_OK = 1;
00651 }
00652
00653 if (m_Cancel > (UINT32) NumButtons)
00654 {
00655 if (IsUserName("Tim"))
00656 {
00657 TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d\n"), m_Cancel, NumButtons);
00658 }
00659
00660
00661
00662 m_Cancel = m_OK;
00663 }
00664
00665 if (m_Help > (UINT32) NumButtons)
00666 {
00667 TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)\n"),
00668 (INT32) m_Help, (INT32) NumButtons);
00669
00670
00671 m_Help = 0;
00672 }
00673
00674
00675 GetDialogInfo();
00676 if (!ValidInfo)
00677 {
00678
00679 goto SevereError;
00680 }
00681
00682
00683 IconPos = DefIconPos;
00684
00685
00686
00687
00688
00689 CDC *pDC;
00690 CFont *OldFont;
00691
00692 pDC = GetDC();
00693 ENSURE(pDC != NULL, "Can't get DC for error box dialog");
00694
00695
00696 if (pDC == NULL)
00697 goto SevereError;
00698
00699 OldFont = pDC->SelectObject(GetFont());
00700
00701
00702
00703 BOOL Success;
00704 Success = SetupButtons(pDC->m_hDC, NumButtons);
00705
00706
00707 Success = Success && SetupMessage(pDC->m_hDC);
00708
00709 if (OldFont != NULL)
00710 pDC->SelectObject(OldFont);
00711
00712
00713 ReleaseDC(pDC);
00714
00715
00716
00717 if (!Success)
00718 goto SevereError;
00719
00720
00721 UINT32 TitleID;
00722 TitleID = m_TitleStr;
00723 switch (m_ErrorBoxType)
00724 {
00725 case ERRORTYPE_NORMAL:
00726
00727 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL);
00728 break;
00729
00730 case ERRORTYPE_QUESTION:
00731 MessageBeep(MB_ICONQUESTION);
00732 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL);
00733 break;
00734
00735 case ERRORTYPE_ERROR:
00736 MessageBeep(MB_ICONEXCLAMATION);
00737 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ERROR);
00738 break;
00739
00740 case ERRORTYPE_WARNING:
00741 MessageBeep(MB_ICONASTERISK);
00742 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_WARNING);
00743 break;
00744
00745 case ERRORTYPE_SERIOUS:
00746 MessageBeep(MB_ICONHAND);
00747 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_SERIOUS);
00748 break;
00749
00750 case ERRORTYPE_ENSURE:
00751 MessageBeep(MB_ICONHAND);
00752 if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ENSURE);
00753 break;
00754
00755 default:
00756 ENSURE(FALSE, "Bad errortype in CInformErrorDialog::OnInitDialog()");
00757 goto SevereError;
00758 break;
00759 }
00760
00761
00762 if (TitleID != 0)
00763 {
00764 String_64 Title(TitleID);
00765 SetWindowText((TCHAR*) Title);
00766 }
00767
00768
00769
00770 INT32 ScreenWidth, ScreenHeight;
00771 ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
00772 ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
00773
00774
00775 RECT DialogRect;
00776 GetWindowRect(&DialogRect);
00777 INT32 DialogWidth, DialogHeight;
00778 DialogWidth = DialogRect.right - DialogRect.left;
00779 DialogHeight = DialogRect.bottom - DialogRect.top;
00780
00781
00782 if (DialogWidth<=0)
00783 DialogWidth = ScreenWidth / 2;
00784 else if (DialogWidth > ScreenWidth)
00785 DialogWidth = ScreenWidth;
00786
00787 if (DialogHeight<=0)
00788 DialogHeight = ScreenHeight / 2;
00789 else if (DialogHeight > ScreenHeight)
00790 DialogHeight = ScreenHeight;
00791
00792
00793 INT32 Left, Top;
00794 Left = (ScreenWidth - DialogWidth) / 2;
00795 Top = (ScreenHeight - DialogHeight) / 2;
00796 SetWindowPos(&wndTop, Left, Top, DialogWidth, DialogHeight, SWP_SHOWWINDOW);
00797
00798
00799 return FALSE;
00800
00801 SevereError:
00802
00803 String_256 Message;
00804
00805
00806 if (m_StaticTextStr == 0)
00807 {
00808
00809 TCHAR *pMsg = Error::GetErrorString();
00810
00811 if ((pMsg == NULL) || (pMsg[0] == 0))
00812 {
00813
00814
00815
00816
00817
00818
00819 #ifdef _DEBUG
00820 if (::MessageBox(ParentHwnd,
00821 "Somebody reported an error without an error message being set.\r"
00822 "Click OK to continue, or Cancel to go into debugger",
00823 "DEBUG Warning from Camelot",
00824 MB_OKCANCEL| MB_SYSTEMMODAL | MB_ICONHAND) == IDCANCEL)
00825 {
00826
00827 DebugBreak();
00828 }
00829 #endif
00830
00831
00832 if (!Message.Load(_R(IDS_ERRORBOX_SPURIOUS)))
00833
00834 goto VerySevereError;
00835
00836
00837 String_64 Title;
00838 if (!Title.Load(_R(IDS_ERRORBOX_WARNING)))
00839 goto VerySevereError;
00840
00841 if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *) Title,
00842 MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0)
00843
00844
00845 goto VerySevereError;
00846
00847
00848 EndDialog((INT32) m_OK);
00849
00850 return TRUE;
00851 }
00852 }
00853
00854
00855
00856
00857 if (!Message.Load(_R(IDS_ERRORBOX_SEVERE)))
00858 goto VerySevereError;
00859
00860 if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle,
00861 MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0)
00862
00863
00864 goto VerySevereError;
00865
00866
00867
00868
00869
00870
00871
00872 UINT32 MBFlags;
00873 MBFlags = MB_SYSTEMMODAL | MB_ICONHAND;
00874
00875
00876 if (m_Cancel != m_OK)
00877 MBFlags |= MB_OKCANCEL;
00878 else
00879 MBFlags |= MB_OK;
00880
00881 if (m_StaticTextStr != 0)
00882 {
00883 if (Message.Load(m_StaticTextStr, m_OwnerModule))
00884 {
00885
00886 INT32 Result = ::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, MBFlags);
00887
00888 if (Result == 0)
00889
00890
00891 goto VerySevereError;
00892
00893 if (Result == IDCANCEL)
00894 {
00895
00896 EndDialog((INT32) m_Cancel);
00897 }
00898 else
00899 {
00900
00901 EndDialog((INT32) m_OK);
00902 }
00903
00904 return TRUE;
00905 }
00906 else
00907 {
00908
00909 goto VerySevereError;
00910 }
00911 }
00912 else
00913 {
00914
00915 TCHAR *pMsg = Error::GetErrorString();
00916
00917 if (pMsg == NULL)
00918
00919 goto VerySevereError;
00920
00921
00922 INT32 Result = ::MessageBox(ParentHwnd, pMsg, (TCHAR *)BoxTitle, MBFlags);
00923
00924 if (Result == 0)
00925
00926
00927 goto VerySevereError;
00928
00929 if (Result == IDCANCEL)
00930 {
00931
00932 EndDialog((INT32) m_Cancel);
00933 }
00934 else
00935 {
00936
00937 EndDialog((INT32) m_OK);
00938 }
00939
00940 return TRUE;
00941 }
00942
00943 VerySevereError:
00944
00945
00946 ::MessageBox(ParentHwnd, (TCHAR *)VerySeriousError, (TCHAR *)BoxTitle, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND);
00947
00948
00949 EndDialog((INT32) m_OK);
00950
00951 return TRUE;
00952 }
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971 void CInformErrorDialog::OnPaint()
00972 {
00973 CPaintDC dc(this);
00974
00975 HICON hIcon;
00976 CWinApp *pApp = AfxGetApp();
00977
00978 ENSURE(pApp != NULL, "Could not get application object in CInformErrorDialog::OnPaint()");
00979 if (pApp == NULL)
00980 return;
00981
00982 switch (m_ErrorBoxType)
00983 {
00984 case ERRORTYPE_NORMAL:
00985 hIcon = pApp->LoadIcon(_R(IDR_MAINFRAME));
00986 break;
00987
00988 case ERRORTYPE_QUESTION:
00989
00990
00991
00992
00993 hIcon = pApp->LoadStandardIcon(_R(IDI_EXCLAMATION));
00994 break;
00995
00996 case ERRORTYPE_ERROR:
00997 hIcon = pApp->LoadStandardIcon(_R(IDI_EXCLAMATION));
00998 break;
00999
01000 case ERRORTYPE_WARNING:
01001 hIcon = pApp->LoadStandardIcon(_R(IDI_ASTERISK));
01002 break;
01003
01004 case ERRORTYPE_SERIOUS:
01005 case ERRORTYPE_ENSURE:
01006 hIcon = pApp->LoadStandardIcon(_R(IDI_HAND));
01007 break;
01008
01009 default:
01010 ENSURE(FALSE, "Bad errortype in CInformErrorDialog::OnPaint()");
01011 return;
01012 }
01013
01014
01015 ENSURE(hIcon != NULL, "Could not load icon in CInformErrorDialog::OnPaint()");
01016 if (hIcon != NULL)
01017 {
01018
01019 dc.DrawIcon(IconPos.x, IconPos.y, hIcon);
01020 }
01021
01022
01023 }
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041 void CInformErrorDialog::OnClickedButton1()
01042 {
01043 HandleButton(1);
01044 }
01045
01046
01047 void CInformErrorDialog::OnClickedButton2()
01048 {
01049 HandleButton(2);
01050 }
01051
01052
01053 void CInformErrorDialog::OnClickedButton3()
01054 {
01055 HandleButton(3);
01056 }
01057
01058
01059 void CInformErrorDialog::OnClickedButton4()
01060 {
01061 HandleButton(4);
01062 }
01063
01064
01065 void CInformErrorDialog::OnClickedButton5()
01066 {
01067 HandleButton(5);
01068 }
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084 void CInformErrorDialog::HandleButton(UINT32 idButton)
01085 {
01086
01087 if (idButton == m_Help)
01088 {
01089 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
01090
01091 HelpUser(m_nHelpContext);
01092 #endif
01093 }
01094 else
01095 {
01096
01097 EndDialog((INT32) idButton);
01098 }
01099 }
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114 void CInformErrorDialog::OnCancelCmd()
01115 {
01116
01117 EndDialog((INT32) m_Cancel);
01118 }
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135 CWnd* CInformErrorDialog::GetSafeParent()
01136 {
01137 CWnd *Parent = NULL;
01138
01139 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
01140
01141 Parent = CSplashDialog::GetpWnd();
01142
01143 if (Parent)
01144 return Parent;
01145 #endif
01146
01147
01148 #ifndef WEBSTER
01149 #ifndef STANDALONE
01150
01151 Parent = CCPrintDialog::GetPrintCWnd();
01152 if (Parent)
01153 return Parent;
01154 #endif
01155 #endif //webster
01156
01157
01158 Parent = GetMainFrame();
01159 if (Parent && Parent->IsWindowVisible())
01160 return Parent;
01161 return NULL;
01162 }