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 6806 - (hide annotations) (download) (as text)
Thu Jun 15 00:37:01 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: 8862 byte(s)
TeraTerm Project としてのライセンス表記を追加

とりあえず Tera Term 本体分。
TeraTerm Project としての copyright 表記の年部分はコミットログを確認して書いたつもりだけど、ミスってたらすみません。

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

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