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 6841 - (hide annotations) (download) (as text)
Tue Jul 4 15:02:28 2017 UTC (6 years, 9 months ago) by doda
Original Path: trunk/teraterm/teraterm/ftdlg.cpp
File MIME type: text/x-c++src
File size: 8858 byte(s)
TeraTerm Project としてのライセンス表記を追加

・Tera Term 本体分を横 80 桁に収まるように改行位置を調整
・ttssh 関連の分を追加
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3     * (C) 2007-2017 TeraTerm Project
4     * All rights reserved.
5     *
6 doda 6841 * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9 doda 6806 *
10 doda 6841 * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17 doda 6806 *
18 doda 6841 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 doda 6806 */
29 maya 3227
30     /* TERATERM.EXE, file transfer dialog box */
31     #include "stdafx.h"
32     #include "teraterm.h"
33     #include "tttypes.h"
34     #include "ttftypes.h"
35     #include "ttlib.h"
36     #include "tt_res.h"
37     #include "ftdlg.h"
38    
39     #ifdef _DEBUG
40     #define new DEBUG_NEW
41     #undef THIS_FILE
42     static char THIS_FILE[] = __FILE__;
43     #endif
44    
45     /////////////////////////////////////////////////////////////////////////////
46     // CFileTransDlg dialog
47    
48     BEGIN_MESSAGE_MAP(CFileTransDlg, CDialog)
49     //{{AFX_MSG_MAP(CFileTransDlg)
50     //}}AFX_MSG_MAP
51     END_MESSAGE_MAP()
52    
53     BOOL CFileTransDlg::Create(PFileVar pfv, PComVar pcv, PTTSet pts)
54     {
55 maya 3392 BOOL Ok;
56     WNDCLASS wc;
57     int fuLoad = LR_DEFAULTCOLOR;
58 maya 4822 HWND hwnd;
59 maya 3227
60 maya 3392 fv = pfv;
61     cv = pcv;
62     cv->FilePause &= ~fv->OpId;
63     ts = pts;
64     LOGFONT logfont;
65     HFONT font;
66 maya 3227
67 maya 3392 wc.style = CS_PARENTDC;
68     wc.lpfnWndProc = AfxWndProc;
69     wc.cbClsExtra = 0;
70     wc.cbWndExtra = DLGWINDOWEXTRA;
71     wc.hInstance = AfxGetInstanceHandle();
72     wc.hIcon = NULL;
73     wc.hCursor = LoadCursor(NULL,IDC_ARROW);
74     wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
75     wc.lpszMenuName = NULL;
76     wc.lpszClassName = "FTDlg32";
77     RegisterClass(&wc);
78 maya 3227
79 maya 3392 Pause = FALSE;
80 maya 4822 hwnd = GetForegroundWindow()->GetSafeHwnd();
81 maya 3392 if (fv->OpId == OpLog) { // parent window is desktop
82     Ok = CDialog::Create(CFileTransDlg::IDD, GetDesktopWindow());
83     }
84     else { // parent window is VT window
85 maya 3596 Ok = CDialog::Create(CFileTransDlg::IDD, NULL);
86 maya 3392 }
87 maya 3227
88 maya 3392 if (!fv->HideDialog) {
89 maya 4818 // Visible = False ���_�C�A���O���\������
90 maya 3709 ShowWindow(SW_SHOWNORMAL);
91 maya 3392 if (fv->OpId == OpLog) {
92     ShowWindow(SW_MINIMIZE);
93     }
94     }
95 maya 3596 else {
96 maya 4822 // ���O���t�H�A�O���E���h�������E�B���h�E���t�H�[�J�X�������B
97     // ���j���[�������O���X�^�[�g�������� VTWin ���t�H�[�J�X���������������K�v�������B
98 maya 3600 ::SetForegroundWindow(hwnd);
99 maya 3596 }
100 maya 3227
101 maya 3392 fv->HWin = GetSafeHwnd();
102 maya 3227
103 maya 3392 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
104     GetObject(font, sizeof(LOGFONT), &logfont);
105     if (get_lang_font("DLG_SYSTEM_FONT", fv->HWin, &logfont, &DlgFont, ts->UILanguageFile)) {
106     SendDlgItemMessage(IDC_TRANS_FILENAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
107     SendDlgItemMessage(IDC_TRANSFNAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
108     SendDlgItemMessage(IDC_FULLPATH_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
109     SendDlgItemMessage(IDC_EDIT_FULLPATH, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
110     SendDlgItemMessage(IDC_TRANS_TRANS, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
111     SendDlgItemMessage(IDC_TRANSBYTES, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
112 doda 4461 SendDlgItemMessage(IDC_TRANS_ELAPSED, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
113     SendDlgItemMessage(IDC_TRANS_ETIME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
114 maya 3392 SendDlgItemMessage(IDC_TRANSPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
115     SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
116     SendDlgItemMessage(IDC_TRANSHELP, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
117     }
118 maya 3227
119 maya 3392 return Ok;
120 maya 3227 }
121    
122     void CFileTransDlg::ChangeButton(BOOL PauseFlag)
123     {
124 maya 3392 Pause = PauseFlag;
125     if (Pause) {
126     get_lang_msg("DLG_FILETRANS_START", ts->UIMsg, sizeof(ts->UIMsg), "&Start", ts->UILanguageFile);
127     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
128     cv->FilePause |= fv->OpId;
129     }
130     else {
131     get_lang_msg("DLG_FILETRANS_PAUSE", ts->UIMsg, sizeof(ts->UIMsg), "Pau&se", ts->UILanguageFile);
132     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
133     cv->FilePause &= ~fv->OpId;
134     }
135 maya 3227 }
136    
137     void CFileTransDlg::RefreshNum()
138     {
139 maya 3392 char NumStr[24];
140     double rate;
141 doda 4454 int rate2;
142     static DWORD prev_elapsed;
143     DWORD elapsed;
144 maya 3227
145 doda 4454 if (fv->OpId == OpSendFile) {
146     if (fv->StartTime == 0) {
147 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, "0:00");
148 doda 4454 prev_elapsed = 0;
149     }
150     else {
151     elapsed = (GetTickCount() - fv->StartTime) / 1000;
152     if (elapsed != prev_elapsed && elapsed != 0) {
153     rate2 = fv->ByteCount / elapsed;
154     if (rate2 < 1200) {
155     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%dBytes/s)", elapsed / 60, elapsed % 60, rate2);
156     }
157     else if (rate2 < 1200000) {
158     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dKB/s)", elapsed / 60, elapsed % 60, rate2 / 1000, rate2 / 10 % 100);
159     }
160     else {
161     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dMB/s)", elapsed / 60, elapsed % 60, rate2 / (1000*1000), rate2 / 10000 % 100);
162     }
163 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, NumStr);
164 doda 4454 prev_elapsed = elapsed;
165     }
166     }
167     }
168    
169 maya 3392 if (fv->OpId == OpSendFile && fv->FileSize > 0) {
170     rate = 100.0 * (double)fv->ByteCount / (double)fv->FileSize;
171     if (fv->ProgStat < (int)rate) {
172     fv->ProgStat = (int)rate;
173     SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)fv->ProgStat, 0);
174     }
175     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)",fv->ByteCount, rate);
176     }
177     else {
178     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u",fv->ByteCount);
179     }
180     SetDlgItemText(IDC_TRANSBYTES, NumStr);
181 maya 3227 }
182    
183     /////////////////////////////////////////////////////////////////////////////
184     // CFileTransDlg message handler
185    
186     BOOL CFileTransDlg::OnInitDialog()
187     {
188 maya 3392 int fuLoad = LR_DEFAULTCOLOR;
189 maya 3227
190 maya 4822 if (fv->HideDialog) {
191     // Visible = False �����t�H�A�O���E���h�����������������A������������
192     // �������g���X�^�C�� WS_EX_NOACTIVATE ���w�������B
193     // (Windows 2000 �������L��)
194     // WS_EX_NOACTIVATE ���w���������\�����������������^�X�N�o�[����������
195     // ���� WS_EX_APPWINDOW ���w�������B
196     ModifyStyleEx(0, WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
197     }
198    
199 maya 3392 SetWindowText(fv->DlgCaption);
200     SetDlgItemText(IDC_TRANSFNAME, &(fv->FullName[fv->DirLen]));
201 maya 3227
202 maya 3392 // ���O�t�@�C�����t���p�X�\��������(2004.8.6 yutaka)
203     SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0]));
204 maya 3227
205 yutakapon 6286 if (IsWindowsNT4()) {
206 maya 3392 fuLoad = LR_VGACOLOR;
207     }
208 yutakapon 6504 SmallIcon = LoadImage(AfxGetInstanceHandle(),
209     MAKEINTRESOURCE(IDI_TTERM),
210     IMAGE_ICON, 16, 16, fuLoad);
211     ::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_SMALL,
212     (LPARAM)SmallIcon);
213 maya 3227
214 yutakapon 6504 BigIcon = LoadImage(AfxGetInstanceHandle(),
215     MAKEINTRESOURCE(IDI_TTERM),
216     IMAGE_ICON, 0, 0, fuLoad);
217     ::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
218     (LPARAM)BigIcon);
219    
220 maya 3392 return 1;
221 maya 3227 }
222    
223     void CFileTransDlg::OnCancel( )
224     {
225 maya 3392 ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
226 maya 3227 }
227    
228 doda 6435 BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
229 maya 3227 {
230 maya 3392 switch (LOWORD(wParam)) {
231     case IDCANCEL:
232     ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
233     return TRUE;
234     case IDC_TRANSPAUSESTART:
235     ChangeButton(! Pause);
236     return TRUE;
237     case IDC_TRANSHELP:
238     ::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0);
239     return TRUE;
240     default:
241     return (CDialog::OnCommand(wParam,lParam));
242     }
243 maya 3227 }
244    
245     void CFileTransDlg::PostNcDestroy()
246     {
247 yutakapon 6504 // logopen��logclose���J���������AGDI���\�[�X���[�N�������������C�������B
248     // - CreateFontIndirect()�����������_���t�H���g�����������B
249     // - LoadImage()�������A�C�R�����\�[�X�����������B
250     // (2016.10.5 yutaka)
251 yutakapon 6501 if (DlgFont) {
252     DeleteObject(DlgFont);
253     DlgFont = NULL;
254     }
255    
256 yutakapon 6504 if (SmallIcon) {
257     DestroyIcon((HICON)SmallIcon);
258     SmallIcon = NULL;
259     }
260    
261     if (BigIcon) {
262     DestroyIcon((HICON)BigIcon);
263     BigIcon = NULL;
264     }
265    
266 maya 3392 delete this;
267 maya 3227 }
268    
269     LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
270     {
271 maya 3392 return DefDlgProc(GetSafeHwnd(),message,wParam,lParam);
272 maya 3227 }

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