00001
00002
00003
00004
00005 #include "ProgressTextDLG.h"
00006
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014
00015 using namespace jbxl;
00016 using namespace jbxwl;
00017
00018
00020
00021
00022 CProgressTextDLG::CProgressTextDLG(LPCTSTR tn, BOOL edp, CWnd* pParent)
00023 : CDialog(CProgressTextDLG::IDD, pParent)
00024 {
00025
00026
00027
00028
00029 dialogID = CProgressTextDLG::IDD;
00030 pWnd = pParent;
00031 title = tn;
00032 enableDisPatcher = edp;
00033 dCounter = NULL;
00034 }
00035
00036
00037
00038 CProgressTextDLG::CProgressTextDLG(UINT nIDTemplate, LPCTSTR tn, BOOL edp, CWnd* pParent)
00039 : CDialog(nIDTemplate, pParent)
00040 {
00041 dialogID = nIDTemplate;
00042 pWnd = pParent;
00043 title = tn;
00044 enableDisPatcher = edp;
00045 dCounter = NULL;
00046 }
00047
00048
00049
00050 void CProgressTextDLG::DoDataExchange(CDataExchange* pDX)
00051 {
00052 CDialog::DoDataExchange(pDX);
00053
00054
00055
00056 }
00057
00058
00059
00060 BEGIN_MESSAGE_MAP(CProgressTextDLG, CDialog)
00061
00062
00063 END_MESSAGE_MAP()
00064
00065
00066
00068
00069
00070 BOOL CProgressTextDLG::OnInitDialog()
00071 {
00072 dCounter = (CStatic*)GetDlgItem(IDC_PROGTEXT_MSG);
00073 return TRUE;
00074 }
00075
00076
00077
00078
00079
00080
00081 void CProgressTextDLG::Start(int m, char* tn)
00082 {
00083 cancel = false;
00084 max = m;
00085
00086 Create(dialogID, pWnd);
00087 ShowWindow(SW_SHOW);
00088 if (tn!=NULL) title = mbs2ts(tn);
00089 if (!title.IsEmpty()) SetWindowText(title);
00090 start = true;
00091
00092
00093 }
00094
00095
00096
00097
00098
00099 void CProgressTextDLG::Stop()
00100 {
00101 pos = 0;
00102 title = _T("");
00103 cancel = false;
00104 start = false;
00105
00106 DestroyWindow();
00107 }
00108
00109
00110
00111 void CProgressTextDLG::StepIt(int n)
00112 {
00113 pos += n;
00114 DispCounter(pos);
00115
00116 if (enableDisPatcher) DisPatcher();
00117 }
00118
00119
00120
00121 void CProgressTextDLG::SetPos(int num)
00122 {
00123 pos = num;
00124 DispCounter(pos);
00125
00126 if (enableDisPatcher) DisPatcher();
00127 }
00128
00129
00130
00131
00132
00133 void CProgressTextDLG::SetTitle(char* tn)
00134 {
00135 if (tn!=NULL) title = mbs2ts(tn);
00136 if (start) SetWindowText(title);
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 BOOL CProgressTextDLG::OnCommand(WPARAM wParam, LPARAM lParam)
00155 {
00156 if (wParam==IDCANCEL) {
00157 cancel = true;
00158 CString mesg;
00159 mesg.LoadString(IDS_STR_CANCELING);
00160 SetWindowText(mesg);
00161 }
00162
00163 return TRUE;
00164
00165
00166 }
00167
00168
00169
00170 void CProgressTextDLG::DispCounter(int n)
00171 {
00172 if (n<0) dCounter->SetWindowText(_T("-----"));
00173 else {
00174 TCHAR buf[LNAME];
00175
00176 sntprintf(buf, LNAME, _T("%d") , n);
00177 dCounter->SetWindowText(buf);
00178 }
00179 }
00180
00181