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 4818 - (hide annotations) (download) (as text)
Fri Feb 3 15:48:21 2012 UTC (12 years, 2 months ago) by maya
Original Path: trunk/teraterm/teraterm/ftdlg.cpp
File MIME type: text/x-c++src
File size: 6523 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 if (!fv->HideDialog) {
63 maya 4818 // Visible = False ���_�C�A���O���\������
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 doda 4461 SendDlgItemMessage(IDC_TRANS_ELAPSED, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
85     SendDlgItemMessage(IDC_TRANS_ETIME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
86 maya 3392 SendDlgItemMessage(IDC_TRANSPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
87     SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
88     SendDlgItemMessage(IDC_TRANSHELP, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
89     }
90 maya 3227
91 maya 3392 return Ok;
92 maya 3227 }
93    
94     void CFileTransDlg::ChangeButton(BOOL PauseFlag)
95     {
96 maya 3392 Pause = PauseFlag;
97     if (Pause) {
98     get_lang_msg("DLG_FILETRANS_START", ts->UIMsg, sizeof(ts->UIMsg), "&Start", ts->UILanguageFile);
99     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
100     cv->FilePause |= fv->OpId;
101     }
102     else {
103     get_lang_msg("DLG_FILETRANS_PAUSE", ts->UIMsg, sizeof(ts->UIMsg), "Pau&se", ts->UILanguageFile);
104     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
105     cv->FilePause &= ~fv->OpId;
106     }
107 maya 3227 }
108    
109     void CFileTransDlg::RefreshNum()
110     {
111 maya 3392 char NumStr[24];
112     double rate;
113 doda 4454 int rate2;
114     static DWORD prev_elapsed;
115     DWORD elapsed;
116 maya 3227
117 doda 4454 if (fv->OpId == OpSendFile) {
118     if (fv->StartTime == 0) {
119 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, "0:00");
120 doda 4454 prev_elapsed = 0;
121     }
122     else {
123     elapsed = (GetTickCount() - fv->StartTime) / 1000;
124     if (elapsed != prev_elapsed && elapsed != 0) {
125     rate2 = fv->ByteCount / elapsed;
126     if (rate2 < 1200) {
127     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%dBytes/s)", elapsed / 60, elapsed % 60, rate2);
128     }
129     else if (rate2 < 1200000) {
130     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dKB/s)", elapsed / 60, elapsed % 60, rate2 / 1000, rate2 / 10 % 100);
131     }
132     else {
133     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dMB/s)", elapsed / 60, elapsed % 60, rate2 / (1000*1000), rate2 / 10000 % 100);
134     }
135 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, NumStr);
136 doda 4454 prev_elapsed = elapsed;
137     }
138     }
139     }
140    
141 maya 3392 if (fv->OpId == OpSendFile && fv->FileSize > 0) {
142     rate = 100.0 * (double)fv->ByteCount / (double)fv->FileSize;
143     if (fv->ProgStat < (int)rate) {
144     fv->ProgStat = (int)rate;
145     SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)fv->ProgStat, 0);
146     }
147     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)",fv->ByteCount, rate);
148     }
149     else {
150     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u",fv->ByteCount);
151     }
152     SetDlgItemText(IDC_TRANSBYTES, NumStr);
153 maya 3227 }
154    
155     /////////////////////////////////////////////////////////////////////////////
156     // CFileTransDlg message handler
157    
158     BOOL CFileTransDlg::OnInitDialog()
159     {
160 maya 3392 int fuLoad = LR_DEFAULTCOLOR;
161 maya 3227
162 maya 3392 SetWindowText(fv->DlgCaption);
163     SetDlgItemText(IDC_TRANSFNAME, &(fv->FullName[fv->DirLen]));
164 maya 3227
165 maya 3392 // ���O�t�@�C�����t���p�X�\��������(2004.8.6 yutaka)
166     SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0]));
167 maya 3227
168 maya 3392 if (is_NT4()) {
169     fuLoad = LR_VGACOLOR;
170     }
171     ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_SMALL,
172     (LPARAM)LoadImage(AfxGetInstanceHandle(),
173     MAKEINTRESOURCE(IDI_TTERM),
174     IMAGE_ICON,16,16,fuLoad));
175     ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_BIG,
176     (LPARAM)LoadImage(AfxGetInstanceHandle(),
177     MAKEINTRESOURCE(IDI_TTERM),
178     IMAGE_ICON, 0, 0, fuLoad));
179 maya 3227
180 maya 3392 return 1;
181 maya 3227 }
182    
183     void CFileTransDlg::OnCancel( )
184     {
185 maya 3392 ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
186 maya 3227 }
187    
188     BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
189     {
190 maya 3392 switch (LOWORD(wParam)) {
191     case IDCANCEL:
192     ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
193     return TRUE;
194     case IDC_TRANSPAUSESTART:
195     ChangeButton(! Pause);
196     return TRUE;
197     case IDC_TRANSHELP:
198     ::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0);
199     return TRUE;
200     default:
201     return (CDialog::OnCommand(wParam,lParam));
202     }
203 maya 3227 }
204    
205     void CFileTransDlg::PostNcDestroy()
206     {
207 maya 3392 delete this;
208 maya 3227 }
209    
210     LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
211     {
212 maya 3392 return DefDlgProc(GetSafeHwnd(),message,wParam,lParam);
213 maya 3227 }

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