ProgDlg.cpp
00001
00002
00003
00004 #include "stdafx.h"
00005 #include "resource.h"
00006 #include "ProgDlg.h"
00007
00008 #ifdef _DEBUG
00009 #undef THIS_FILE
00010 static char BASED_CODE THIS_FILE[] = __FILE__;
00011 #endif
00012
00014
00015
00016 CExportingDlg::CExportingDlg(UINT nCaptionID)
00017 {
00018 m_nCaptionID = CG_IDS_PROGRESS_CAPTION;
00019 if (nCaptionID != 0)
00020 m_nCaptionID = nCaptionID;
00021
00022 m_bCancel=FALSE;
00023 m_nLower=0;
00024 m_nUpper=100;
00025 m_nStep=1;
00026
00027
00028
00029 m_bParentDisabled = FALSE;
00030 }
00031
00032 CExportingDlg::~CExportingDlg()
00033 {
00034 if(m_hWnd!=NULL)
00035 DestroyWindow();
00036 }
00037
00038 BOOL CExportingDlg::DestroyWindow()
00039 {
00040 ReEnableParent();
00041 return CDialog::DestroyWindow();
00042 }
00043
00044 void CExportingDlg::ReEnableParent()
00045 {
00046 if(m_bParentDisabled && (m_pParentWnd!=NULL))
00047 m_pParentWnd->EnableWindow(TRUE);
00048 m_bParentDisabled=FALSE;
00049 }
00050
00051 BOOL CExportingDlg::Create(CWnd *pParent)
00052 {
00053
00054 m_pParentWnd = CWnd::GetSafeOwner(pParent);
00055
00056
00057
00058
00059
00060 if((m_pParentWnd!=NULL) && m_pParentWnd->IsWindowEnabled())
00061 {
00062 m_pParentWnd->EnableWindow(FALSE);
00063 m_bParentDisabled = TRUE;
00064 }
00065
00066 if(!CDialog::Create(CExportingDlg::IDD,pParent))
00067 {
00068 ReEnableParent();
00069 return FALSE;
00070 }
00071
00072 return TRUE;
00073 }
00074
00075 void CExportingDlg::DoDataExchange(CDataExchange* pDX)
00076 {
00077 CDialog::DoDataExchange(pDX);
00078
00079 DDX_Control(pDX, CG_IDC_PROGDLG_PROGRESS, m_Progress);
00080
00081 }
00082
00083 BEGIN_MESSAGE_MAP(CExportingDlg, CDialog)
00084
00085
00086 END_MESSAGE_MAP()
00087
00088 void CExportingDlg::SetStatus(LPCTSTR lpszMessage)
00089 {
00090 ASSERT(m_hWnd);
00091
00092 CWnd *pWndStatus = GetDlgItem(CG_IDC_PROGDLG_STATUS);
00093
00094
00095 ASSERT(pWndStatus!=NULL);
00096 pWndStatus->SetWindowText(lpszMessage);
00097 }
00098
00099 void CExportingDlg::OnCancel()
00100 {
00101 m_bCancel=TRUE;
00102 }
00103
00104 void CExportingDlg::SetRange(int nLower,int nUpper)
00105 {
00106 m_nLower = nLower;
00107 m_nUpper = nUpper;
00108 m_Progress.SetRange(nLower,nUpper);
00109 }
00110
00111 int CExportingDlg::SetPos(int nPos)
00112 {
00113 PumpMessages();
00114 int iResult = m_Progress.SetPos(nPos);
00115 UpdatePercent(nPos);
00116 return iResult;
00117 }
00118
00119 int CExportingDlg::SetStep(int nStep)
00120 {
00121 m_nStep = nStep;
00122 return m_Progress.SetStep(nStep);
00123 }
00124
00125 int CExportingDlg::OffsetPos(int nPos)
00126 {
00127 PumpMessages();
00128 int iResult = m_Progress.OffsetPos(nPos);
00129 UpdatePercent(iResult+nPos);
00130 return iResult;
00131 }
00132
00133 int CExportingDlg::StepIt()
00134 {
00135 PumpMessages();
00136 int iResult = m_Progress.StepIt();
00137 UpdatePercent(iResult+m_nStep);
00138 return iResult;
00139 }
00140
00141 void CExportingDlg::PumpMessages()
00142 {
00143
00144 ASSERT(m_hWnd!=NULL);
00145
00146 MSG msg;
00147
00148 while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
00149 {
00150 if(!IsDialogMessage(&msg))
00151 {
00152 TranslateMessage(&msg);
00153 DispatchMessage(&msg);
00154 }
00155 }
00156 }
00157
00158 BOOL CExportingDlg::CheckCancelButton()
00159 {
00160
00161 PumpMessages();
00162
00163
00164
00165
00166
00167
00168
00169
00170 BOOL bResult = m_bCancel;
00171 m_bCancel = FALSE;
00172
00173 return bResult;
00174 }
00175
00176 void CExportingDlg::UpdatePercent(int nNewPos)
00177 {
00178 CWnd *pWndPercent = GetDlgItem(CG_IDC_PROGDLG_PERCENT);
00179 int nPercent;
00180
00181 int nDivisor = m_nUpper - m_nLower;
00182 ASSERT(nDivisor>0);
00183
00184 int nDividend = (nNewPos - m_nLower);
00185 ASSERT(nDividend>=0);
00186
00187 nPercent = nDividend * 100 / nDivisor;
00188
00189
00190
00191 if(nPercent!=100)
00192 nPercent %= 100;
00193
00194
00195 CString strBuf;
00196 strBuf.Format(_T("%d/%d文書 (%d%c)"),nNewPos ,m_nUpper, nPercent, _T('%'));
00197
00198 CString strCur;
00199 pWndPercent->GetWindowText(strCur);
00200
00201 if (strCur != strBuf)
00202 pWndPercent->SetWindowText(strBuf);
00203 }
00204
00206
00207
00208 BOOL CExportingDlg::OnInitDialog()
00209 {
00210 CDialog::OnInitDialog();
00211 m_Progress.SetRange(m_nLower,m_nUpper);
00212 m_Progress.SetStep(m_nStep);
00213 m_Progress.SetPos(m_nLower);
00214
00215 CString strCaption;
00216 VERIFY(strCaption.LoadString(m_nCaptionID));
00217 SetWindowText(strCaption);
00218
00219 return TRUE;
00220 }
00221
00222 BOOL CExportingDlg::PreTranslateMessage(MSG* pMsg)
00223 {
00224
00225 if (pMsg->message == 0x4d) {
00226
00227 if (GetKeyState(VK_SHIFT) >= 0) {
00228
00229
00230 OnCommandHelp(0, 0);
00231
00232 return(TRUE);
00233 }
00234
00235 else {
00236
00237 SendMessage(WM_SYSCOMMAND, SC_CONTEXTHELP);
00238 return(TRUE);
00239 }
00240
00241 }
00242
00243 return CDialog::PreTranslateMessage(pMsg);
00244 }
LotusNotes CSV Export Plug-inに対してWed Jun 30 15:53:52 2004に生成されました。
1.3.7