| 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 |
|
|
BOOL Ok; |
| 31 |
|
|
WNDCLASS wc; |
| 32 |
|
|
int fuLoad = LR_DEFAULTCOLOR; |
| 33 |
|
|
|
| 34 |
|
|
fv = pfv; |
| 35 |
|
|
cv = pcv; |
| 36 |
|
|
cv->FilePause &= ~fv->OpId; |
| 37 |
|
|
ts = pts; |
| 38 |
|
|
LOGFONT logfont; |
| 39 |
|
|
HFONT font; |
| 40 |
|
|
|
| 41 |
|
|
wc.style = CS_PARENTDC; |
| 42 |
|
|
wc.lpfnWndProc = AfxWndProc; |
| 43 |
|
|
wc.cbClsExtra = 0; |
| 44 |
|
|
wc.cbWndExtra = DLGWINDOWEXTRA; |
| 45 |
|
|
wc.hInstance = AfxGetInstanceHandle(); |
| 46 |
|
|
wc.hIcon = NULL; |
| 47 |
|
|
wc.hCursor = LoadCursor(NULL,IDC_ARROW); |
| 48 |
|
|
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); |
| 49 |
|
|
wc.lpszMenuName = NULL; |
| 50 |
|
|
wc.lpszClassName = "FTDlg32"; |
| 51 |
|
|
RegisterClass(&wc); |
| 52 |
|
|
|
| 53 |
|
|
Pause = FALSE; |
| 54 |
|
|
if (fv->OpId == OpLog) // parent window is desktop |
| 55 |
|
|
Ok = CDialog::Create(CFileTransDlg::IDD, GetDesktopWindow()); |
| 56 |
|
|
else // parent window is VT window |
| 57 |
|
|
Ok = CDialog::Create(CFileTransDlg::IDD, NULL); |
| 58 |
|
|
|
| 59 |
|
|
// �����o������������ (2009.2.7 maya) |
| 60 |
|
|
if (!fv->HideDialog) { |
| 61 |
|
|
ShowWindow(SW_SHOW); |
| 62 |
|
|
if (fv->OpId == OpLog) { |
| 63 |
|
|
ShowWindow(SW_MINIMIZE); |
| 64 |
|
|
} |
| 65 |
|
|
} |
| 66 |
|
|
|
| 67 |
|
|
fv->HWin = GetSafeHwnd(); |
| 68 |
|
|
|
| 69 |
|
|
font = (HFONT)SendMessage(WM_GETFONT, 0, 0); |
| 70 |
|
|
GetObject(font, sizeof(LOGFONT), &logfont); |
| 71 |
|
|
if (get_lang_font("DLG_SYSTEM_FONT", fv->HWin, &logfont, &DlgFont, ts->UILanguageFile)) { |
| 72 |
|
|
SendDlgItemMessage(IDC_TRANS_FILENAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 73 |
|
|
SendDlgItemMessage(IDC_TRANSFNAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 74 |
|
|
SendDlgItemMessage(IDC_FULLPATH_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 75 |
|
|
SendDlgItemMessage(IDC_EDIT_FULLPATH, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 76 |
|
|
SendDlgItemMessage(IDC_TRANS_TRANS, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 77 |
|
|
SendDlgItemMessage(IDC_TRANSBYTES, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 78 |
|
|
SendDlgItemMessage(IDC_TRANSPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 79 |
|
|
SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 80 |
|
|
SendDlgItemMessage(IDC_TRANSHELP, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); |
| 81 |
|
|
} |
| 82 |
|
|
|
| 83 |
|
|
return Ok; |
| 84 |
|
|
} |
| 85 |
|
|
|
| 86 |
|
|
void CFileTransDlg::ChangeButton(BOOL PauseFlag) |
| 87 |
|
|
{ |
| 88 |
|
|
Pause = PauseFlag; |
| 89 |
|
|
if (Pause) |
| 90 |
|
|
{ |
| 91 |
|
|
get_lang_msg("DLG_FILETRANS_START", ts->UIMsg, sizeof(ts->UIMsg), "&Start", ts->UILanguageFile); |
| 92 |
|
|
SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg); |
| 93 |
|
|
cv->FilePause |= fv->OpId; |
| 94 |
|
|
} |
| 95 |
|
|
else { |
| 96 |
|
|
get_lang_msg("DLG_FILETRANS_PAUSE", ts->UIMsg, sizeof(ts->UIMsg), "Pau&se", ts->UILanguageFile); |
| 97 |
|
|
SetDlgItemText(IDC_TRANSPAUSESTART, ts->UIMsg); |
| 98 |
|
|
cv->FilePause &= ~fv->OpId; |
| 99 |
|
|
} |
| 100 |
|
|
} |
| 101 |
|
|
|
| 102 |
|
|
void CFileTransDlg::RefreshNum() |
| 103 |
|
|
{ |
| 104 |
|
|
char NumStr[24]; |
| 105 |
|
|
double rate; |
| 106 |
|
|
|
| 107 |
|
|
if (fv->OpId == OpSendFile && fv->FileSize > 0) { |
| 108 |
|
|
rate = 100.0 * (double)fv->ByteCount / (double)fv->FileSize; |
| 109 |
|
|
if (fv->ProgStat < (int)rate) { |
| 110 |
|
|
fv->ProgStat = (int)rate; |
| 111 |
|
|
SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)fv->ProgStat, 0); |
| 112 |
|
|
} |
| 113 |
|
|
_snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)",fv->ByteCount, rate); |
| 114 |
|
|
} |
| 115 |
|
|
else { |
| 116 |
|
|
_snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u",fv->ByteCount); |
| 117 |
|
|
} |
| 118 |
|
|
SetDlgItemText(IDC_TRANSBYTES, NumStr); |
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
|
|
///////////////////////////////////////////////////////////////////////////// |
| 122 |
|
|
// CFileTransDlg message handler |
| 123 |
|
|
|
| 124 |
|
|
BOOL CFileTransDlg::OnInitDialog() |
| 125 |
|
|
{ |
| 126 |
|
|
int fuLoad = LR_DEFAULTCOLOR; |
| 127 |
|
|
|
| 128 |
|
|
SetWindowText(fv->DlgCaption); |
| 129 |
|
|
SetDlgItemText(IDC_TRANSFNAME, &(fv->FullName[fv->DirLen])); |
| 130 |
|
|
|
| 131 |
|
|
// ���O�t�@�C�����t���p�X�\��������(2004.8.6 yutaka) |
| 132 |
|
|
SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0])); |
| 133 |
|
|
|
| 134 |
|
|
if (is_NT4()) { |
| 135 |
|
|
fuLoad = LR_VGACOLOR; |
| 136 |
|
|
} |
| 137 |
|
|
::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_SMALL, |
| 138 |
|
|
(LPARAM)LoadImage(AfxGetInstanceHandle(), |
| 139 |
|
|
MAKEINTRESOURCE(IDI_TTERM), |
| 140 |
|
|
IMAGE_ICON,16,16,fuLoad)); |
| 141 |
|
|
::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_BIG, |
| 142 |
|
|
(LPARAM)LoadImage(AfxGetInstanceHandle(), |
| 143 |
|
|
MAKEINTRESOURCE(IDI_TTERM), |
| 144 |
|
|
IMAGE_ICON, 0, 0, fuLoad)); |
| 145 |
|
|
|
| 146 |
|
|
return 1; |
| 147 |
|
|
} |
| 148 |
|
|
|
| 149 |
|
|
void CFileTransDlg::OnCancel( ) |
| 150 |
|
|
{ |
| 151 |
|
|
::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0); |
| 152 |
|
|
} |
| 153 |
|
|
|
| 154 |
|
|
BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam) |
| 155 |
|
|
{ |
| 156 |
|
|
switch (LOWORD(wParam)) { |
| 157 |
|
|
case IDCANCEL: |
| 158 |
|
|
::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0); |
| 159 |
|
|
return TRUE; |
| 160 |
|
|
case IDC_TRANSPAUSESTART: |
| 161 |
|
|
ChangeButton(! Pause); |
| 162 |
|
|
return TRUE; |
| 163 |
|
|
case IDC_TRANSHELP: |
| 164 |
|
|
::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0); |
| 165 |
|
|
return TRUE; |
| 166 |
|
|
default: |
| 167 |
|
|
return (CDialog::OnCommand(wParam,lParam)); |
| 168 |
|
|
} |
| 169 |
|
|
} |
| 170 |
|
|
|
| 171 |
|
|
void CFileTransDlg::PostNcDestroy() |
| 172 |
|
|
{ |
| 173 |
|
|
delete this; |
| 174 |
|
|
} |
| 175 |
|
|
|
| 176 |
|
|
LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) |
| 177 |
|
|
{ |
| 178 |
|
|
return DefDlgProc(GetSafeHwnd(),message,wParam,lParam); |
| 179 |
|
|
} |