00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "WaitForConfirmationDlg.h"
00009 #include "system.h"
00010
00011 #ifdef _DEBUG
00012 #define new DEBUG_NEW
00013 #undef THIS_FILE
00014 static char THIS_FILE[] = __FILE__;
00015 #endif
00016
00017 CWaitForConfirmationDlg::CWaitForConfirmationDlg(CWnd* pParent )
00018 : CDialog(CWaitForConfirmationDlg::IDD, pParent)
00019 {
00020 m_bShowDontAsk = FALSE;
00021 m_bNoIsDefault = FALSE;
00022 m_bDontAsk = FALSE;
00023 m_pszIcon = IDI_QUESTION;
00024 }
00025
00026 void CWaitForConfirmationDlg::DoDataExchange(CDataExchange* pDX)
00027 {
00028 CDialog::DoDataExchange(pDX);
00029
00030
00031
00032 }
00033
00034 BEGIN_MESSAGE_MAP(CWaitForConfirmationDlg, CDialog)
00035
00036 ON_WM_TIMER()
00037 ON_WM_CONTEXTMENU()
00038 ON_COMMAND(ID_WHATISTHIS, OnWhatisthis)
00039 ON_BN_CLICKED(IDC_DONTASK, OnDontask)
00040
00041 END_MESSAGE_MAP()
00042
00043 void CWaitForConfirmationDlg::Init(LPCSTR pszMsg, UINT uWait, BOOL bShowDontAsk, BOOL bNoIsDefault, LPCSTR pszDontAskAgainText, LPCSTR pszMsgIfDontAskAgain)
00044 {
00045 m_msg = pszMsg;
00046 m_wait = uWait;
00047 m_bShowDontAsk = bShowDontAsk;
00048 m_bNoIsDefault = bNoIsDefault;
00049
00050 if (pszDontAskAgainText)
00051 m_strDontAskAgainText = pszDontAskAgainText;
00052 else
00053 m_strDontAskAgainText = "";
00054
00055 if (pszMsgIfDontAskAgain)
00056 m_strMsgIfDontAskAfain = pszMsgIfDontAskAgain;
00057 else
00058 m_strMsgIfDontAskAfain = "";
00059 }
00060
00061 BOOL CWaitForConfirmationDlg::OnInitDialog()
00062 {
00063 CDialog::OnInitDialog();
00064
00065 SetDlgItemText (IDC__MESSAGE, m_msg);
00066 ((CStatic*) GetDlgItem (IDC_DLGICON))->SetIcon (::LoadIcon (NULL, m_pszIcon));
00067
00068 fsSetForegroundWindow (m_hWnd);
00069 ::SetWindowPos (m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
00070
00071 ApplyLanguage ();
00072
00073 if (m_strDontAskAgainText.GetLength () != 0)
00074 SetDlgItemText (IDC_DONTASK, m_strDontAskAgainText);
00075
00076
00077 if (m_wait != UINT_MAX)
00078 {
00079 SetTimer (1, 1000, NULL);
00080 SetTimerText ();
00081 }
00082
00083 GetDlgItem (IDC_DONTASK)->ShowWindow (m_bShowDontAsk ? SW_SHOW : SW_HIDE);
00084 m_bDontAsk = FALSE;
00085
00086 return TRUE;
00087
00088 }
00089
00090 void CWaitForConfirmationDlg::OnTimer(UINT nIDEvent)
00091 {
00092
00093
00094 if (--m_wait == 0)
00095 EndDialog (m_bNoIsDefault ? IDCANCEL : IDOK);
00096 else
00097 SetTimerText ();
00098
00099
00100
00101 CDialog::OnTimer(nIDEvent);
00102
00103
00104 }
00105
00106 void CWaitForConfirmationDlg::SetTimerText()
00107 {
00108 CString str;
00109 str.Format ("%s (%d)", m_bNoIsDefault ? LS (L_NO) : LS (L_YES), m_wait);
00110 SetDlgItemText (m_bNoIsDefault ? IDCANCEL : IDOK, str);
00111 }
00112
00113 void CWaitForConfirmationDlg::OnContextMenu(CWnd* , CPoint point)
00114 {
00115 fsCtrlContextHelp aCH1 [] = {
00116 fsCtrlContextHelp (IDOK, "Perform operation"),
00117 fsCtrlContextHelp (IDCANCEL, "Cancel operation"),
00118 };
00119
00120 static fsCtrlContextHelp aCH [sizeof (aCH1) / sizeof (fsCtrlContextHelp)];
00121 CopyMemory (aCH, aCH1, sizeof (aCH));
00122
00123 _CHMgr.PrepareContextMenu (this, point, aCH, sizeof (aCH) / sizeof (fsCtrlContextHelp));
00124 _CHMgr.ShowMenu ();
00125 }
00126
00127 void CWaitForConfirmationDlg::OnWhatisthis()
00128 {
00129 _CHMgr.OnWT ();
00130 }
00131
00132 void CWaitForConfirmationDlg::ApplyLanguage()
00133 {
00134 fsDlgLngInfo lnginfo [] = {
00135 fsDlgLngInfo (IDOK, L_YES),
00136 fsDlgLngInfo (IDCANCEL, L_NO),
00137 fsDlgLngInfo (IDC_DONTASK, L_DONTASKAGAIN),
00138 };
00139
00140 _LngMgr.ApplyLanguage (this, lnginfo, sizeof (lnginfo) / sizeof (fsDlgLngInfo), L_CONFIRMATION);
00141 }
00142
00143 void CWaitForConfirmationDlg::OnDontask()
00144 {
00145 m_bDontAsk = IsDlgButtonChecked (IDC_DONTASK) == BST_CHECKED;
00146 }
00147
00148 void CWaitForConfirmationDlg::OnOK()
00149 {
00150 DoPostDlg ();
00151 CDialog::OnOK();
00152 }
00153
00154 void CWaitForConfirmationDlg::OnCancel()
00155 {
00156 DoPostDlg ();
00157 CDialog::OnCancel();
00158 }
00159
00160 void CWaitForConfirmationDlg::DoPostDlg()
00161 {
00162 if (m_bDontAsk && m_strMsgIfDontAskAfain.GetLength () != 0)
00163 MessageBox (m_strMsgIfDontAskAfain, PRG_NAME, MB_OK);
00164 }