Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/ftdlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4454 - (hide annotations) (download) (as text)
Tue Apr 19 13:23:37 2011 UTC (12 years, 11 months ago) by doda
Original Path: trunk/teraterm/teraterm/ftdlg.cpp
File MIME type: text/x-c++src
File size: 6338 byte(s)
ファイル転送ダイアログ/ファイル送信ダイアログで、経過時間と転送速度を表示するようにした。

1 maya 3227 /* Tera Term
2     Copyright(C) 1994-1998 T. Teranishi
3     All rights reserved. */
4    
5     /* TERATERM.EXE, file transfer dialog box */
6     #include "stdafx.h"
7     #include "teraterm.h"
8     #include "tttypes.h"
9     #include "ttftypes.h"
10     #include "ttlib.h"
11     #include "tt_res.h"
12     #include "ftdlg.h"
13    
14     #ifdef _DEBUG
15     #define new DEBUG_NEW
16     #undef THIS_FILE
17     static char THIS_FILE[] = __FILE__;
18     #endif
19    
20     /////////////////////////////////////////////////////////////////////////////
21     // CFileTransDlg dialog
22    
23     BEGIN_MESSAGE_MAP(CFileTransDlg, CDialog)
24     //{{AFX_MSG_MAP(CFileTransDlg)
25     //}}AFX_MSG_MAP
26     END_MESSAGE_MAP()
27    
28     BOOL CFileTransDlg::Create(PFileVar pfv, PComVar pcv, PTTSet pts)
29     {
30 maya 3392 BOOL Ok;
31     WNDCLASS wc;
32     int fuLoad = LR_DEFAULTCOLOR;
33 maya 3600 HWND hwnd = GetForegroundWindow()->GetSafeHwnd();
34 maya 3227
35 maya 3392 fv = pfv;
36     cv = pcv;
37     cv->FilePause &= ~fv->OpId;
38     ts = pts;
39     LOGFONT logfont;
40     HFONT font;
41 maya 3227
42 maya 3392 wc.style = CS_PARENTDC;
43     wc.lpfnWndProc = AfxWndProc;
44     wc.cbClsExtra = 0;
45     wc.cbWndExtra = DLGWINDOWEXTRA;
46     wc.hInstance = AfxGetInstanceHandle();
47     wc.hIcon = NULL;
48     wc.hCursor = LoadCursor(NULL,IDC_ARROW);
49     wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
50     wc.lpszMenuName = NULL;
51     wc.lpszClassName = "FTDlg32";
52     RegisterClass(&wc);
53 maya 3227
54 maya 3392 Pause = FALSE;
55     if (fv->OpId == OpLog) { // parent window is desktop
56     Ok = CDialog::Create(CFileTransDlg::IDD, GetDesktopWindow());
57     }
58     else { // parent window is VT window
59 maya 3596 Ok = CDialog::Create(CFileTransDlg::IDD, NULL);
60 maya 3392 }
61 maya 3227
62 maya 3392 // �����o������������ (2009.2.7 maya)
63     if (!fv->HideDialog) {
64 maya 3709 ShowWindow(SW_SHOWNORMAL);
65 maya 3392 if (fv->OpId == OpLog) {
66     ShowWindow(SW_MINIMIZE);
67     }
68     }
69 maya 3596 else {
70 maya 3600 ::SetForegroundWindow(hwnd);
71 maya 3596 }
72 maya 3227
73 maya 3392 fv->HWin = GetSafeHwnd();
74 maya 3227
75 maya 3392 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
76     GetObject(font, sizeof(LOGFONT), &logfont);
77     if (get_lang_font("DLG_SYSTEM_FONT", fv->HWin, &logfont, &DlgFont, ts->UILanguageFile)) {
78     SendDlgItemMessage(IDC_TRANS_FILENAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
79     SendDlgItemMessage(IDC_TRANSFNAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
80     SendDlgItemMessage(IDC_FULLPATH_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
81     SendDlgItemMessage(IDC_EDIT_FULLPATH, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
82     SendDlgItemMessage(IDC_TRANS_TRANS, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
83     SendDlgItemMessage(IDC_TRANSBYTES, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
84     SendDlgItemMessage(IDC_TRANSPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
85     SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
86     SendDlgItemMessage(IDC_TRANSHELP, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
87     }
88 maya 3227
89 maya 3392 return Ok;
90 maya 3227 }
91    
92     void CFileTransDlg::ChangeButton(BOOL PauseFlag)
93     {
94 maya 3392 Pause = PauseFlag;
95     if (Pause) {
96     get_lang_msg("DLG_FILETRANS_START", ts->UIMsg, sizeof(ts->UIMsg), "&Start", ts->UILanguageFile);
97     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
98     cv->FilePause |= fv->OpId;
99     }
100     else {
101     get_lang_msg("DLG_FILETRANS_PAUSE", ts->UIMsg, sizeof(ts->UIMsg), "Pau&se", ts->UILanguageFile);
102     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
103     cv->FilePause &= ~fv->OpId;
104     }
105 maya 3227 }
106    
107     void CFileTransDlg::RefreshNum()
108     {
109 maya 3392 char NumStr[24];
110     double rate;
111 doda 4454 int rate2;
112     static DWORD prev_elapsed;
113     DWORD elapsed;
114 maya 3227
115 doda 4454 if (fv->OpId == OpSendFile) {
116     if (fv->StartTime == 0) {
117     SetDlgItemText(IDC_ELAPSEDTIME, "0:00");
118     prev_elapsed = 0;
119     }
120     else {
121     elapsed = (GetTickCount() - fv->StartTime) / 1000;
122     if (elapsed != prev_elapsed && elapsed != 0) {
123     rate2 = fv->ByteCount / elapsed;
124     if (rate2 < 1200) {
125     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%dBytes/s)", elapsed / 60, elapsed % 60, rate2);
126     }
127     else if (rate2 < 1200000) {
128     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dKB/s)", elapsed / 60, elapsed % 60, rate2 / 1000, rate2 / 10 % 100);
129     }
130     else {
131     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dMB/s)", elapsed / 60, elapsed % 60, rate2 / (1000*1000), rate2 / 10000 % 100);
132     }
133     SetDlgItemText(IDC_ELAPSEDTIME, NumStr);
134     prev_elapsed = elapsed;
135     }
136     }
137     }
138    
139 maya 3392 if (fv->OpId == OpSendFile && fv->FileSize > 0) {
140     rate = 100.0 * (double)fv->ByteCount / (double)fv->FileSize;
141     if (fv->ProgStat < (int)rate) {
142     fv->ProgStat = (int)rate;
143     SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)fv->ProgStat, 0);
144     }
145     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)",fv->ByteCount, rate);
146     }
147     else {
148     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u",fv->ByteCount);
149     }
150     SetDlgItemText(IDC_TRANSBYTES, NumStr);
151 maya 3227 }
152    
153     /////////////////////////////////////////////////////////////////////////////
154     // CFileTransDlg message handler
155    
156     BOOL CFileTransDlg::OnInitDialog()
157     {
158 maya 3392 int fuLoad = LR_DEFAULTCOLOR;
159 maya 3227
160 maya 3392 SetWindowText(fv->DlgCaption);
161     SetDlgItemText(IDC_TRANSFNAME, &(fv->FullName[fv->DirLen]));
162 maya 3227
163 maya 3392 // ���O�t�@�C�����t���p�X�\��������(2004.8.6 yutaka)
164     SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0]));
165 maya 3227
166 maya 3392 if (is_NT4()) {
167     fuLoad = LR_VGACOLOR;
168     }
169     ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_SMALL,
170     (LPARAM)LoadImage(AfxGetInstanceHandle(),
171     MAKEINTRESOURCE(IDI_TTERM),
172     IMAGE_ICON,16,16,fuLoad));
173     ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_BIG,
174     (LPARAM)LoadImage(AfxGetInstanceHandle(),
175     MAKEINTRESOURCE(IDI_TTERM),
176     IMAGE_ICON, 0, 0, fuLoad));
177 maya 3227
178 maya 3392 return 1;
179 maya 3227 }
180    
181     void CFileTransDlg::OnCancel( )
182     {
183 maya 3392 ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
184 maya 3227 }
185    
186     BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
187     {
188 maya 3392 switch (LOWORD(wParam)) {
189     case IDCANCEL:
190     ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
191     return TRUE;
192     case IDC_TRANSPAUSESTART:
193     ChangeButton(! Pause);
194     return TRUE;
195     case IDC_TRANSHELP:
196     ::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0);
197     return TRUE;
198     default:
199     return (CDialog::OnCommand(wParam,lParam));
200     }
201 maya 3227 }
202    
203     void CFileTransDlg::PostNcDestroy()
204     {
205 maya 3392 delete this;
206 maya 3227 }
207    
208     LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
209     {
210 maya 3392 return DefDlgProc(GetSafeHwnd(),message,wParam,lParam);
211 maya 3227 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26