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 7528 - (hide annotations) (download) (as text)
Thu Mar 28 16:38:54 2019 UTC (5 years ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/ftdlg.cpp
File MIME type: text/x-c++src
File size: 7598 byte(s)
vtwin,teratermでMFCを使用しないようにした
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 zmatsuo 7526 * (C) 2007-2019 TeraTerm Project
4 doda 6806 * 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 zmatsuo 7526 #include <stdio.h>
32     #include <windows.h>
33     #include <commctrl.h>
34     #include <tchar.h>
35 maya 3227 #include "teraterm.h"
36     #include "tttypes.h"
37     #include "ttftypes.h"
38     #include "ttlib.h"
39 zmatsuo 7526 #include "dlglib.h"
40 maya 3227 #include "tt_res.h"
41     #include "ftdlg.h"
42 zmatsuo 7528 #include "teraterml.h"
43 maya 3227
44     #ifdef _DEBUG
45     #define new DEBUG_NEW
46     #undef THIS_FILE
47     static char THIS_FILE[] = __FILE__;
48     #endif
49    
50     /////////////////////////////////////////////////////////////////////////////
51     // CFileTransDlg dialog
52    
53 zmatsuo 7526 BOOL CFileTransDlg::Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PComVar pcv, PTTSet pts)
54 maya 3227 {
55 maya 3392 BOOL Ok;
56     int fuLoad = LR_DEFAULTCOLOR;
57 maya 4822 HWND hwnd;
58 maya 3227
59 maya 3392 fv = pfv;
60     cv = pcv;
61     cv->FilePause &= ~fv->OpId;
62     ts = pts;
63 maya 3227
64 maya 3392 Pause = FALSE;
65 zmatsuo 7526 hwnd = GetForegroundWindow();
66 maya 3392 if (fv->OpId == OpLog) { // parent window is desktop
67 zmatsuo 7526 Ok = TTCDialog::Create(hInstance, GetDesktopWindow(), CFileTransDlg::IDD);
68 maya 3392 }
69     else { // parent window is VT window
70 zmatsuo 7526 Ok = TTCDialog::Create(hInstance, NULL, CFileTransDlg::IDD);
71 maya 3392 }
72 maya 3227
73 maya 3392 if (!fv->HideDialog) {
74 maya 4818 // Visible = False ���_�C�A���O���\������
75 maya 3709 ShowWindow(SW_SHOWNORMAL);
76 maya 3392 if (fv->OpId == OpLog) {
77     ShowWindow(SW_MINIMIZE);
78     }
79     }
80 maya 3596 else {
81 maya 4822 // ���O���t�H�A�O���E���h�������E�B���h�E���t�H�[�J�X�������B
82     // ���j���[�������O���X�^�[�g�������� VTWin ���t�H�[�J�X���������������K�v�������B
83 maya 3600 ::SetForegroundWindow(hwnd);
84 maya 3596 }
85 maya 3227
86 maya 3392 fv->HWin = GetSafeHwnd();
87 maya 3227
88 maya 3392 return Ok;
89 maya 3227 }
90    
91     void CFileTransDlg::ChangeButton(BOOL PauseFlag)
92     {
93 maya 3392 Pause = PauseFlag;
94     if (Pause) {
95     get_lang_msg("DLG_FILETRANS_START", ts->UIMsg, sizeof(ts->UIMsg), "&Start", ts->UILanguageFile);
96     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
97     cv->FilePause |= fv->OpId;
98     }
99     else {
100     get_lang_msg("DLG_FILETRANS_PAUSE", ts->UIMsg, sizeof(ts->UIMsg), "Pau&se", ts->UILanguageFile);
101     SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg);
102     cv->FilePause &= ~fv->OpId;
103     }
104 maya 3227 }
105    
106     void CFileTransDlg::RefreshNum()
107     {
108 maya 3392 char NumStr[24];
109     double rate;
110 doda 4454 int rate2;
111     static DWORD prev_elapsed;
112     DWORD elapsed;
113 maya 3227
114 doda 4454 if (fv->OpId == OpSendFile) {
115     if (fv->StartTime == 0) {
116 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, "0:00");
117 doda 4454 prev_elapsed = 0;
118     }
119     else {
120     elapsed = (GetTickCount() - fv->StartTime) / 1000;
121     if (elapsed != prev_elapsed && elapsed != 0) {
122     rate2 = fv->ByteCount / elapsed;
123     if (rate2 < 1200) {
124     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%dBytes/s)", elapsed / 60, elapsed % 60, rate2);
125     }
126     else if (rate2 < 1200000) {
127     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dKB/s)", elapsed / 60, elapsed % 60, rate2 / 1000, rate2 / 10 % 100);
128     }
129     else {
130     _snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%d:%02d (%d.%02dMB/s)", elapsed / 60, elapsed % 60, rate2 / (1000*1000), rate2 / 10000 % 100);
131     }
132 doda 4461 SetDlgItemText(IDC_TRANS_ETIME, NumStr);
133 doda 4454 prev_elapsed = elapsed;
134     }
135     }
136     }
137    
138 maya 3392 if (fv->OpId == OpSendFile && fv->FileSize > 0) {
139     rate = 100.0 * (double)fv->ByteCount / (double)fv->FileSize;
140     if (fv->ProgStat < (int)rate) {
141     fv->ProgStat = (int)rate;
142     SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)fv->ProgStat, 0);
143     }
144     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)",fv->ByteCount, rate);
145     }
146     else {
147     _snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u",fv->ByteCount);
148     }
149     SetDlgItemText(IDC_TRANSBYTES, NumStr);
150 maya 3227 }
151    
152     /////////////////////////////////////////////////////////////////////////////
153     // CFileTransDlg message handler
154    
155     BOOL CFileTransDlg::OnInitDialog()
156     {
157 zmatsuo 7526 static const DlgTextInfo TextInfos[] = {
158     { IDC_TRANS_FILENAME, "DLG_FILETRANS_FILENAME" },
159     { IDC_FULLPATH_LABEL, "DLG_FILETRANS_FULLPATH" },
160     { IDC_TRANS_TRANS, "DLG_FILETRANS_TRNAS" },
161     { IDC_TRANS_ELAPSED, "DLG_FILETRANS_ELAPSED" },
162     { IDCANCEL, "DLG_FILETRANS_CLOSE" },
163     { IDC_TRANSPAUSESTART, "DLG_FILETRANS_PAUSE" },
164     { IDC_TRANSHELP, "BTN_HELP" },
165     };
166    
167 maya 3392 int fuLoad = LR_DEFAULTCOLOR;
168 maya 3227
169 maya 4822 if (fv->HideDialog) {
170     // Visible = False �����t�H�A�O���E���h�����������������A������������
171     // �������g���X�^�C�� WS_EX_NOACTIVATE ���w�������B
172     // (Windows 2000 �������L��)
173     // WS_EX_NOACTIVATE ���w���������\�����������������^�X�N�o�[����������
174     // ���� WS_EX_APPWINDOW ���w�������B
175     ModifyStyleEx(0, WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
176     }
177    
178 maya 3392 SetWindowText(fv->DlgCaption);
179     SetDlgItemText(IDC_TRANSFNAME, &(fv->FullName[fv->DirLen]));
180 maya 3227
181 maya 3392 // ���O�t�@�C�����t���p�X�\��������(2004.8.6 yutaka)
182     SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0]));
183 maya 3227
184 zmatsuo 7526 SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts->UILanguageFile);
185    
186 yutakapon 6286 if (IsWindowsNT4()) {
187 maya 3392 fuLoad = LR_VGACOLOR;
188     }
189 zmatsuo 7526 SmallIcon = LoadImage(m_hInst,
190     MAKEINTRESOURCE(IDI_TTERM),
191     IMAGE_ICON, 16, 16, fuLoad);
192 yutakapon 6504 ::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_SMALL,
193 zmatsuo 7526 (LPARAM)SmallIcon);
194 maya 3227
195 zmatsuo 7526 BigIcon = LoadImage(m_hInst,
196     MAKEINTRESOURCE(IDI_TTERM),
197     IMAGE_ICON, 0, 0, fuLoad);
198 yutakapon 6504 ::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
199 zmatsuo 7526 (LPARAM)BigIcon);
200 yutakapon 6504
201 zmatsuo 7526 AddModalHandle(m_hWnd);
202    
203     return TRUE;
204 maya 3227 }
205    
206 zmatsuo 7526 BOOL CFileTransDlg::OnCancel( )
207 maya 3227 {
208 maya 3392 ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
209 zmatsuo 7526 return TRUE;
210 maya 3227 }
211    
212 doda 6435 BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
213 maya 3227 {
214 maya 3392 switch (LOWORD(wParam)) {
215     case IDCANCEL:
216     ::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
217     return TRUE;
218     case IDC_TRANSPAUSESTART:
219     ChangeButton(! Pause);
220     return TRUE;
221     case IDC_TRANSHELP:
222     ::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0);
223     return TRUE;
224     default:
225 zmatsuo 7526 return (TTCDialog::OnCommand(wParam,lParam));
226 maya 3392 }
227 maya 3227 }
228    
229 zmatsuo 7526 BOOL CFileTransDlg::PostNcDestroy()
230 maya 3227 {
231 yutakapon 6504 // logopen��logclose���J���������AGDI���\�[�X���[�N�������������C�������B
232     // - LoadImage()�������A�C�R�����\�[�X�����������B
233     // (2016.10.5 yutaka)
234     if (SmallIcon) {
235     DestroyIcon((HICON)SmallIcon);
236     SmallIcon = NULL;
237     }
238    
239     if (BigIcon) {
240     DestroyIcon((HICON)BigIcon);
241     BigIcon = NULL;
242     }
243    
244 zmatsuo 7526 RemoveModalHandle(m_hWnd);
245    
246 maya 3392 delete this;
247 zmatsuo 7526 return TRUE;
248 maya 3227 }

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