00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "precomp.h"
00028 #include "CCPrintProgressDlg.h"
00029
00030 #include "globals.h"
00031 #include "debug.h"
00032 #include "commctrl.h"
00033
00035 #define IDT_PROGRESS 0x112
00036
00046 bool CCPrintProgressDlg::DoRequest(HWND hParent, InternetRequest& request, const std::tstring& sRequest, LPCTSTR lpServer , LPCSTR lpOptional , LPCTSTR lpHeaders )
00047 {
00048
00049 if (m_hDlg != NULL)
00050
00051 return false;
00052
00053
00054 m_bCancel = false;
00055 m_bSuccess = false;
00056
00057 m_pRequest = &request;
00058 m_sRequest = sRequest;
00059 m_lpServer = lpServer;
00060 m_lpOptional = lpOptional;
00061 m_lpHeaders = lpHeaders;
00062
00063
00064 DoModal(hParent);
00065
00066
00067 return m_bSuccess;
00068 }
00069
00071 #define MAX_STEP 30
00072
00079 BOOL CCPrintProgressDlg::PageProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
00080 {
00081 switch (uMsg)
00082 {
00083 case WM_INITDIALOG:
00084 {
00085
00086
00087 HWND hProgress = GetDlgItem(IDC_PROGRESS);
00088 SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, MAX_STEP));
00089 m_nStep = 0;
00090 SendMessage(hProgress, PBM_SETPOS, m_nStep, 0);
00091
00092 m_uTimer = (UINT) SetTimer(m_hDlg, IDT_PROGRESS, 200, NULL);
00093
00094
00095 m_pRequest->DoRequestThread(m_sRequest, m_buffer, m_lpServer, m_lpOptional, m_lpHeaders, this);
00096 return TRUE;
00097 }
00098 break;
00099 case WM_COMMAND:
00100
00101 switch(HIWORD(wParam))
00102 {
00103 case BN_CLICKED:
00104 switch(LOWORD(wParam))
00105 {
00106 case IDCANCEL:
00107
00108 m_bCancel = true;
00109 EnableDlgItem(IDCANCEL, FALSE);
00110 return TRUE;
00111 }
00112 break;
00113 }
00114 break;
00115 case WM_TIMER:
00116
00117 if (wParam == IDT_PROGRESS)
00118 {
00119
00120 m_nStep++;
00121 if (m_nStep >= MAX_STEP)
00122
00123 m_nStep = 0;
00124 SendMessage(GetDlgItem(IDC_PROGRESS), PBM_SETPOS, m_nStep, 0);
00125 }
00126 break;
00127 case WM_DESTROY:
00128
00129 if (m_uTimer != 0)
00130 KillTimer(m_hDlg, m_uTimer);
00131 break;
00132 }
00133
00134
00135 return CCPrintDlg::PageProc(uMsg, wParam, lParam);
00136 }
00137
00141 void CCPrintProgressDlg::OnFinished(bool bSuccess)
00142 {
00143
00144 m_bSuccess = bSuccess;
00145
00146 EndDialog(m_hDlg, bSuccess ? IDOK : IDCANCEL);
00147 }