Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1000 lines
21 KiB

  1. /* File: C:\WACKER\TDLL\XFDSPDLG.C (Created: 10-Jan-1994)
  2. * Created from:
  3. * File: C:\HA5G\ha5g\xfdspdlg.c (Created: 9-Oct-1992)
  4. *
  5. * Copyright 1990 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 9 $
  9. * $Date: 10/12/01 5:19p $
  10. */
  11. #include <windows.h>
  12. #pragma hdrstop
  13. // #define DEBUGSTR 1
  14. // As of 14-Apr-94 (build 89) still doesn't work
  15. // As of the May Beta, it did work
  16. #define DO_FM 1
  17. #include <term\res.h>
  18. #include <term\xfer_dlg.h>
  19. #include "stdtyp.h"
  20. #include "mc.h"
  21. #include "tdll.h"
  22. #include "htchar.h"
  23. #include "misc.h"
  24. #include <tdll\assert.h>
  25. #include "session.h"
  26. #include "globals.h"
  27. #include "xfer_msc.h"
  28. #include "xfer_msc.hh"
  29. #include "vu_meter.h"
  30. #include <xfer\xfer.h>
  31. #include "xfdspdlg.h"
  32. #include "xfdspdlg.hh"
  33. #if !defined(DlgParseCmd)
  34. #define DlgParseCmd(i,n,c,w,l) i=LOWORD(w);n=HIWORD(w);c=(HWND)l;
  35. #endif
  36. struct stSaveDlgStuff
  37. {
  38. /*
  39. * Put in whatever else you might need to access later
  40. */
  41. HSESSION hSession;
  42. HWND hDlg; /* our window handle */
  43. HBRUSH hBrush; /* background brush */
  44. XD_TYPE *pstD; /* transfer and display data */
  45. INT nIsCancelActive; /* flag for cancel option */
  46. };
  47. typedef struct stSaveDlgStuff SDS;
  48. VOID PASCAL xfrDisplayFunc(SDS *pstL);
  49. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  50. * FUNCTION:
  51. * XfrDisplayDlg
  52. *
  53. * DESCRIPTION:
  54. * This is the dialog function for the transfer display. It is a little bit
  55. * different in that it is a modeless dialog and it hangs around and shows
  56. * the status of a ongoing transfer.
  57. *
  58. * ARGUMENTS: Standard Windows dialog manager
  59. *
  60. * RETURNS: Standard Windows dialog manager
  61. *
  62. */
  63. INT_PTR CALLBACK XfrDisplayDlg(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  64. {
  65. HWND hwndChild;
  66. INT nId;
  67. INT nNtfy;
  68. SDS *pS;
  69. switch (wMsg)
  70. {
  71. case WM_INITDIALOG:
  72. {
  73. LPTSTR acPtrs[3];
  74. TCHAR acProto[64];
  75. TCHAR acFmt[64];
  76. TCHAR acName[128];
  77. TCHAR acBuffer[256];
  78. pS = (SDS *)malloc(sizeof(SDS));
  79. if (pS == (SDS *)0)
  80. {
  81. /* TODO: decide if we need to display an error here */
  82. EndDialog(hDlg, FALSE);
  83. }
  84. pS->hSession = (HSESSION)lPar;
  85. pS->hDlg = hDlg;
  86. pS->hBrush = 0;
  87. pS->pstD = (XD_TYPE *)sessQueryXferHdl(pS->hSession);
  88. pS->nIsCancelActive = 0;
  89. //
  90. // Make sure to set the loss of carrier flag to FALSE. REV: 08/23/2001
  91. //
  92. if (pS->pstD != (XD_TYPE *)0)
  93. {
  94. pS->pstD->nCarrierLost = FALSE;
  95. }
  96. mscCenterWindowOnWindow(hDlg, sessQueryHwnd(pS->hSession));
  97. /*
  98. * We need to set the title on the display
  99. */
  100. {
  101. int nIndex;
  102. int nState;
  103. XFR_PROTOCOL *pX;
  104. XFR_PARAMS *pP;
  105. /* This section is in braces because it may go into a function later */
  106. pP = (XFR_PARAMS *)0;
  107. xfrQueryParameters(sessQueryXferHdl(pS->hSession), (VOID **)&pP);
  108. assert(pP);
  109. if (pS->pstD->nDirection == XFER_RECV)
  110. nState = pP->nRecProtocol;
  111. else
  112. nState = pP->nSndProtocol;
  113. pX = (XFR_PROTOCOL *)0;
  114. xfrGetProtocols(pS->hSession, &pX);
  115. assert(pX);
  116. if (pX != (XFR_PROTOCOL *)0)
  117. {
  118. for (nIndex = 0; pX[nIndex].nProtocol != 0; nIndex += 1)
  119. {
  120. if (nState == pX[nIndex].nProtocol)
  121. {
  122. StrCharCopy(acProto, pX[nIndex].acName);
  123. break;
  124. }
  125. }
  126. free(pX);
  127. pX = NULL;
  128. }
  129. }
  130. sessQueryName(pS->hSession, acName, sizeof(acName) / sizeof(TCHAR));
  131. LoadString(glblQueryDllHinst(),
  132. (pS->pstD->nDirection == XFER_RECV) ?
  133. IDS_XD_RECV_TITLE : IDS_XD_SEND_TITLE,
  134. acFmt,
  135. sizeof(acFmt) / sizeof(TCHAR));
  136. acPtrs[0] = acProto;
  137. acPtrs[1] = acName;
  138. acPtrs[2] = 0;
  139. #if defined(DO_FM)
  140. FormatMessage(
  141. FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  142. acFmt,
  143. 0, /* Message ID, ignored */
  144. 0, /* also ignored */
  145. acBuffer, /* result */
  146. sizeof(acBuffer) / sizeof(TCHAR),
  147. (va_list *)&acPtrs[0]);
  148. #else
  149. wsprintf(acBuffer, "%s transfer for %s", acPtrs[0], acPtrs[1]);
  150. #endif
  151. SetWindowText(hDlg, acBuffer);
  152. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pS);
  153. }
  154. break;
  155. case WM_CLOSE:
  156. {
  157. XD_TYPE *pX;
  158. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  159. assert(pS);
  160. pX = pS->pstD;
  161. assert(pX);
  162. if (pX)
  163. {
  164. pX->nUserCancel = XFER_ABORT;
  165. }
  166. }
  167. break;
  168. case WM_DESTROY:
  169. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  170. if (pS)
  171. {
  172. /* Free the storeage */
  173. free(pS);
  174. pS = (SDS *)0;
  175. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pS);
  176. }
  177. break;
  178. case WM_DLG_TO_DISPLAY:
  179. // DbgOutStr("WM_DLG_TO_DISPLAY\r\n", 0,0,0,0,0);
  180. switch(wPar)
  181. {
  182. case XFR_SINGLE_TO_DOUBLE:
  183. {
  184. HWND hwndOld;
  185. XD_TYPE *pX;
  186. // DbgOutStr("XFR_SINGLE_TO_DOUBLE\r\n", 0,0,0,0,0);
  187. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  188. if (pS)
  189. {
  190. pX = pS->pstD;
  191. assert(pX);
  192. if (pX->nExpanded)
  193. {
  194. break;
  195. }
  196. pX->nExpanded = TRUE;
  197. if (pX->nLgSingleTemplate == pX->nLgMultiTemplate)
  198. {
  199. break;
  200. }
  201. /* Must actually need to change */
  202. DbgOutStr("New Display!!!\r\n", 0,0,0,0,0);
  203. hwndOld = pX->hwndXfrDisplay;
  204. pX->hwndXfrDisplay = DoModelessDialog(glblQueryDllHinst(),
  205. MAKEINTRESOURCE(pX->nLgMultiTemplate),
  206. sessQueryHwnd(pS->hSession),
  207. XfrDisplayDlg,
  208. (LPARAM)pS->hSession);
  209. assert(pX->hwndXfrDisplay);
  210. //JMH 03-11-96: Originally PostMessage, but it turns out
  211. // some of the flags could be updated and reset by the old
  212. // progress dialog after they were set below. Changing this
  213. // to SemdMessage forces the old dialog to end immediately.
  214. //
  215. PostMessage(sessQueryHwnd(pS->hSession),
  216. WM_SESS_ENDDLG,
  217. 0, (LPARAM)hwndOld);
  218. pX->bChecktype = 1;
  219. pX->bErrorCnt = 1;
  220. pX->bPcktErrCnt = 1;
  221. pX->bLastErrtype = 1;
  222. pX->bTotalSoFar = 1;
  223. pX->bFileSize = 1;
  224. pX->bFileSoFar = 1;
  225. pX->bPacketNumber = 1;
  226. pX->bTotalCnt = 1;
  227. pX->bTotalSize = 1;
  228. pX->bFileCnt = 1;
  229. pX->bEvent = 1;
  230. pX->bStatus = 1;
  231. pX->bElapsedTime = 1;
  232. pX->bRemainingTime = 1;
  233. pX->bThroughput = 1;
  234. pX->bProtocol = 1;
  235. pX->bMessage = 1;
  236. pX->bOurName = 1;
  237. pX->bTheirName = 1;
  238. // xfrDisplayFunc(pS);
  239. PostMessage(pX->hwndXfrDisplay,
  240. WM_DLG_TO_DISPLAY,
  241. XFR_UPDATE_DLG, 0);
  242. }
  243. }
  244. break;
  245. case XFR_BUTTON_PUSHED:
  246. /* Probably not needed any more */
  247. break;
  248. case XFR_UPDATE_DLG:
  249. // DbgOutStr("XFR_UPDATE_DLG\r\n", 0,0,0,0,0);
  250. /* Update the display */
  251. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  252. //assert(pS->pstD->bTheirName == 1);
  253. if (pS)
  254. {
  255. xfrDisplayFunc(pS);
  256. }
  257. break;
  258. default:
  259. break;
  260. }
  261. break;
  262. case WM_COMMAND:
  263. /*
  264. * Did we plan to put a macro in here to do the parsing ?
  265. */
  266. DlgParseCmd(nId, nNtfy, hwndChild, wPar, lPar);
  267. switch (nId)
  268. {
  269. case XFR_SHRINK:
  270. /* Not a feature in Lower Wacker */
  271. break;
  272. case XFR_SKIP:
  273. /* Only for some protocols */
  274. {
  275. XD_TYPE *pX;
  276. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  277. assert(pS);
  278. pX = pS->pstD;
  279. assert(pX);
  280. if (pX)
  281. {
  282. pX->nUserCancel = XFER_SKIP;
  283. }
  284. }
  285. break;
  286. //
  287. // Added XFR_SHUTDOWN back in to allow the session to cancel
  288. // (abort) the transfer when disconnecting. REV: 02/01/2001
  289. //
  290. case XFR_SHUTDOWN:
  291. case XFR_CANCEL: // Yes, XFER_CANCEL and IDCANCEL
  292. case IDCANCEL: // go together. - mrw
  293. {
  294. XD_TYPE *pX;
  295. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  296. assert(pS);
  297. pX = pS->pstD;
  298. assert(pX);
  299. if (pX)
  300. {
  301. pX->nUserCancel = XFER_ABORT;
  302. }
  303. }
  304. break;
  305. case XFER_LOST_CARRIER:
  306. {
  307. XD_TYPE *pX;
  308. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  309. assert(pS);
  310. if (pS)
  311. {
  312. pX = pS->pstD;
  313. assert(pX);
  314. if (pX)
  315. {
  316. pX->nCarrierLost = TRUE;
  317. }
  318. }
  319. }
  320. break;
  321. case XFR_EXPAND:
  322. /* Not a feature in Lower Wacker */
  323. break;
  324. case XFR_CBPS:
  325. {
  326. XD_TYPE *pX;
  327. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  328. assert(pS);
  329. pX = pS->pstD;
  330. assert(pX);
  331. if (pX)
  332. {
  333. if (pX->nBps)
  334. {
  335. pX->nBps = FALSE;
  336. }
  337. else
  338. {
  339. pX->nBps = TRUE;
  340. }
  341. }
  342. }
  343. break;
  344. default:
  345. return FALSE;
  346. }
  347. break;
  348. default:
  349. return FALSE;
  350. }
  351. return TRUE;
  352. }
  353. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  354. * FUNCTION:
  355. * xfrDisplayFunc
  356. *
  357. * DESCRIPTION:
  358. * Multiplex timer callback routine used for transfer display
  359. *
  360. * ARGUMENTS:
  361. * DWORD dwData - double word data value passed thru timer
  362. * ULONG uTime - contains time elapsed.
  363. *
  364. * RETURNS:
  365. * TRUE always
  366. *
  367. */
  368. VOID PASCAL xfrDisplayFunc(SDS *pstL)
  369. {
  370. XD_TYPE *pstD;
  371. HWND hwnd;
  372. UCHAR acBuffer[64];
  373. pstD = pstL->pstD;
  374. //assert(pstD->bTheirName == 1);
  375. if (pstD->bTheirName)
  376. {
  377. hwnd = GetDlgItem(pstL->hDlg, XFR_THEIR_NAME_BOX);
  378. if (hwnd)
  379. {
  380. SetWindowText(hwnd, pstD->acTheirName);
  381. pstD->bTheirName = 0;
  382. }
  383. }
  384. if (pstD->bOurName)
  385. {
  386. hwnd = GetDlgItem(pstL->hDlg, XFR_OUR_NAME_BOX);
  387. if (hwnd)
  388. {
  389. SetWindowText(hwnd, pstD->acOurName);
  390. pstD->bOurName = 0;
  391. }
  392. }
  393. if (pstD->bTotalCnt)
  394. {
  395. if (pstD->wTotalCnt > 1)
  396. {
  397. assert(pstD->hwndXfrDisplay);
  398. if (pstD->hwndXfrDisplay)
  399. {
  400. PostMessage(pstD->hwndXfrDisplay,
  401. WM_DLG_TO_DISPLAY,
  402. XFR_SINGLE_TO_DOUBLE,
  403. 0L);
  404. pstD->bTotalCnt = 0;
  405. return;
  406. }
  407. }
  408. }
  409. if (pstD->bFileCnt)
  410. {
  411. hwnd = GetDlgItem(pstL->hDlg, XFR_FILES_BOX);
  412. if (hwnd)
  413. {
  414. TCHAR acMsg[64];
  415. INT_PTR Args[2];
  416. LoadString(glblQueryDllHinst(),
  417. pstD->wTotalCnt ? IDS_XD_I_OF_I : IDS_XD_ONLY_1,
  418. acMsg,
  419. sizeof(acMsg) / sizeof(TCHAR));
  420. Args[0] = pstD->wFileCnt;
  421. Args[1] = pstD->wTotalCnt;
  422. //
  423. // Make sure to clear out the buffer.
  424. //
  425. TCHAR_Fill(acBuffer, TEXT('\0'), sizeof(acBuffer) / sizeof(TCHAR));
  426. FormatMessage(FORMAT_MESSAGE_FROM_STRING |
  427. FORMAT_MESSAGE_ARGUMENT_ARRAY,
  428. acMsg,
  429. 0,
  430. 0,
  431. acBuffer,
  432. sizeof(acBuffer) / sizeof(TCHAR),
  433. (va_list *)Args);
  434. //wsprintf(acBuffer, acMsg,
  435. // pstD->wFileCnt,
  436. // pstD->wTotalCnt);
  437. #if FALSE
  438. if (pstD->wTotalCnt == 0)
  439. {
  440. wsprintf(acBuffer,
  441. "%d",
  442. pstD->wFileCnt);
  443. }
  444. else
  445. {
  446. wsprintf(acBuffer,
  447. "%d of %d",
  448. pstD->wFileCnt,
  449. pstD->wTotalCnt);
  450. }
  451. #endif
  452. SetWindowText(hwnd, acBuffer);
  453. pstD->bFileCnt = 0;
  454. }
  455. }
  456. if (pstD->bEvent)
  457. {
  458. hwnd = GetDlgItem(pstL->hDlg, XFR_EVENT_BOX);
  459. if (hwnd)
  460. {
  461. TCHAR acMsg[64];
  462. LoadString(glblQueryDllHinst(),
  463. xfrGetEventBase(sessQueryXferHdl(pstL->hSession))
  464. + pstD->wEvent,
  465. acMsg,
  466. sizeof(acMsg) / sizeof(TCHAR));
  467. SetWindowText(hwnd, acMsg);
  468. pstD->bEvent = 0;
  469. }
  470. }
  471. if (pstD->bPacketNumber)
  472. {
  473. hwnd = GetDlgItem(pstL->hDlg, XFR_PACKET_BOX);
  474. if (hwnd)
  475. {
  476. TCHAR acMsg[64];
  477. LoadString(glblQueryDllHinst(),
  478. IDS_XD_INT,
  479. acMsg,
  480. sizeof(acMsg) / sizeof(TCHAR));
  481. wsprintf(acBuffer, acMsg, pstD->lPacketNumber);
  482. SetWindowText(hwnd, acBuffer);
  483. pstD->bPacketNumber = 0;
  484. }
  485. }
  486. if (pstD->bErrorCnt)
  487. {
  488. hwnd = GetDlgItem(pstL->hDlg, XFR_RETRIES_BOX);
  489. if (hwnd)
  490. {
  491. TCHAR acMsg[64];
  492. LoadString(glblQueryDllHinst(),
  493. IDS_XD_INT,
  494. acMsg,
  495. sizeof(acMsg) / sizeof(TCHAR));
  496. wsprintf(acBuffer,
  497. acMsg,
  498. pstD->wErrorCnt);
  499. SetWindowText(hwnd, acBuffer);
  500. pstD->bErrorCnt = 0;
  501. }
  502. }
  503. if (pstD->bStatus)
  504. {
  505. hwnd = GetDlgItem(pstL->hDlg, XFR_STATUS_BOX);
  506. if (hwnd)
  507. {
  508. TCHAR acMsg[64];
  509. LoadString(glblQueryDllHinst(),
  510. xfrGetStatusBase(sessQueryXferHdl(pstL->hSession))
  511. + pstD->wStatus,
  512. acMsg,
  513. sizeof(acMsg) / sizeof(TCHAR));
  514. SetWindowText(hwnd, acMsg);
  515. pstD->bStatus = 0;
  516. }
  517. }
  518. if (pstD->bFileSize)
  519. {
  520. hwnd = GetDlgItem(pstL->hDlg, XFR_FILE_METER);
  521. if (hwnd)
  522. {
  523. PostMessage(hwnd,
  524. WM_VU_SETMAXRANGE,
  525. 0, pstD->lFileSize);
  526. PostMessage(hwnd,
  527. WM_VU_SETCURVALUE,
  528. 0, 0L);
  529. }
  530. hwnd = GetDlgItem(pstL->hDlg, XFR_FILE_SIZE_BOX);
  531. if (hwnd)
  532. {
  533. TCHAR acMsg[64];
  534. LoadString(glblQueryDllHinst(),
  535. IDS_XD_KILO,
  536. acMsg,
  537. sizeof(acMsg) / sizeof(TCHAR));
  538. wsprintf(acBuffer,
  539. acMsg,
  540. (UINT)((pstD->lFileSize + 1023) / 1024)
  541. );
  542. SetWindowText(hwnd, acBuffer);
  543. }
  544. pstD->bFileSize = 0;
  545. }
  546. if (pstD->bFileSoFar)
  547. {
  548. hwnd = GetDlgItem(pstL->hDlg, XFR_FILE_METER);
  549. if (hwnd)
  550. {
  551. PostMessage(hwnd,
  552. WM_VU_SETCURVALUE,
  553. 0, pstD->lFileSoFar);
  554. }
  555. hwnd = GetDlgItem(pstL->hDlg, XFR_FILE_BOX);
  556. if (hwnd)
  557. {
  558. LPTSTR acPtrs[3];
  559. TCHAR acNumF[8];
  560. TCHAR acNum1[32];
  561. TCHAR acNum2[32];
  562. TCHAR acMsg[128];
  563. // DbgOutStr("display filesofar %ld %ld 0x%lx\r\n",
  564. // pstD->lFileSoFar, pstD->lFileSize, pstD, 0,0);
  565. #if FALSE
  566. /* Changed to what follows for Internationalization */
  567. LoadString(glblQueryDllHinst(),
  568. pstD->lFileSize ? IDS_XD_K_OF_K : IDS_XD_KILO,
  569. acMsg,
  570. sizeof(acMsg) / sizeof(TCHAR));
  571. wsprintf(acBuffer, acMsg,
  572. (UINT)((pstD->lFileSoFar + 1023) / 1024),
  573. (UINT)((pstD->lFileSize + 1023) / 1024));
  574. #endif
  575. if (pstD->lFileSize)
  576. {
  577. LoadString(glblQueryDllHinst(),
  578. IDS_XD_K_OF_K,
  579. acMsg,
  580. sizeof(acMsg) / sizeof(TCHAR));
  581. LoadString(glblQueryDllHinst(),
  582. IDS_XD_INT,
  583. acNumF,
  584. sizeof(acNumF) / sizeof(TCHAR));
  585. wsprintf(acNum1, acNumF, ((pstD->lFileSoFar + 1023) / 1024));
  586. wsprintf(acNum2, acNumF, ((pstD->lFileSize + 1023) / 1024));
  587. acPtrs[0] = acNum1;
  588. acPtrs[1] = acNum2;
  589. acPtrs[2] = NULL;
  590. #if defined(DO_FM)
  591. FormatMessage(
  592. FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  593. acMsg,
  594. 0, /* String ID, ignored */
  595. 0, /* Also ignored */
  596. acBuffer,
  597. sizeof(acBuffer) / sizeof(TCHAR),
  598. (va_list *)&acPtrs[0]
  599. );
  600. #else
  601. wsprintf(acBuffer, "%sK of %sK", acPtrs[0], acPtrs[1]);
  602. #endif
  603. }
  604. else
  605. {
  606. LoadString(glblQueryDllHinst(),
  607. IDS_XD_KILO,
  608. acMsg,
  609. sizeof(acMsg) / sizeof(TCHAR));
  610. wsprintf(acBuffer, acMsg,
  611. (UINT)((pstD->lFileSoFar + 1023) / 1024),
  612. (UINT)((pstD->lFileSize + 1023) / 1024));
  613. }
  614. SetWindowText(hwnd, acBuffer);
  615. }
  616. pstD->bFileSoFar = 0;
  617. }
  618. if (pstD->bTotalSoFar)
  619. {
  620. hwnd = GetDlgItem(pstL->hDlg, XFR_TOTAL_METER);
  621. // DbgOutStr("TotalSoFar %ld 0x%x\r\n", pstD->lTotalSoFar, hwnd, 0,0,0);
  622. if (hwnd)
  623. {
  624. PostMessage(hwnd,
  625. WM_VU_SETCURVALUE,
  626. 0, pstD->lTotalSoFar);
  627. }
  628. hwnd = GetDlgItem(pstL->hDlg, XFR_TOTAL_BOX);
  629. if (hwnd)
  630. {
  631. LPTSTR acPtrs[3];
  632. TCHAR acNumF[8];
  633. TCHAR acNum1[32];
  634. TCHAR acNum2[32];
  635. TCHAR acMsg[128];
  636. // DbgOutStr("display totalsofar %ld %ld 0x%lx\r\n",
  637. // pstD->lTotalSoFar, pstD->lTotalSize, pstD, 0,0);
  638. #if FALSE
  639. /* Changed to what follows for Internationalization */
  640. LoadString(glblQueryDllHinst(),
  641. pstD->lTotalSize ? IDS_XD_K_OF_K : IDS_XD_KILO,
  642. acMsg,
  643. sizeof(acMsg) / sizeof(TCHAR));
  644. wsprintf(acBuffer, acMsg,
  645. (UINT)((pstD->lTotalSoFar + 1023) / 1024),
  646. (UINT)((pstD->lTotalSize + 1023) / 1024)
  647. );
  648. #endif
  649. if (pstD->lFileSize)
  650. {
  651. LoadString(glblQueryDllHinst(),
  652. IDS_XD_K_OF_K,
  653. acMsg,
  654. sizeof(acMsg) / sizeof(TCHAR));
  655. LoadString(glblQueryDllHinst(),
  656. IDS_XD_INT,
  657. acNumF,
  658. sizeof(acNumF) / sizeof(TCHAR));
  659. wsprintf(acNum1, acNumF, ((pstD->lTotalSoFar + 1023) / 1024));
  660. wsprintf(acNum2, acNumF, ((pstD->lTotalSize + 1023) / 1024));
  661. acPtrs[0] = acNum1;
  662. acPtrs[1] = acNum2;
  663. acPtrs[2] = NULL;
  664. #if defined(DO_FM)
  665. FormatMessage(
  666. FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  667. acMsg,
  668. 0, /* String ID, ignored */
  669. 0, /* Also ignored */
  670. acBuffer,
  671. sizeof(acBuffer) / sizeof(TCHAR),
  672. (va_list *)&acPtrs[0]
  673. );
  674. #else
  675. wsprintf(acBuffer, "%sK of %sK", acPtrs[0], acPtrs[1]);
  676. #endif
  677. }
  678. else
  679. {
  680. LoadString(glblQueryDllHinst(),
  681. IDS_XD_KILO,
  682. acMsg,
  683. sizeof(acMsg) / sizeof(TCHAR));
  684. wsprintf(acBuffer, acMsg,
  685. (UINT)((pstD->lTotalSoFar + 1023) / 1024),
  686. (UINT)((pstD->lTotalSize + 1023) / 1024));
  687. }
  688. SetWindowText(hwnd, acBuffer);
  689. }
  690. if (pstD->lTotalSize != 0)
  691. {
  692. xfrSetPercentDone(sessQueryXferHdl(pstL->hSession),
  693. (int)((pstD->lTotalSoFar * 100L) / pstD->lTotalSize));
  694. }
  695. pstD->bTotalSoFar = 0;
  696. }
  697. if (pstD->bTotalSize)
  698. {
  699. hwnd = GetDlgItem(pstL->hDlg, XFR_TOTAL_METER);
  700. // DbgOutStr("TotalSize %ld 0x%x\r\n", pstD->lTotalSize, hwnd, 0,0,0);
  701. if (hwnd)
  702. {
  703. PostMessage(hwnd,
  704. WM_VU_SETMAXRANGE,
  705. 0, pstD->lTotalSize);
  706. PostMessage(hwnd,
  707. WM_VU_SETCURVALUE,
  708. 0, 0L);
  709. pstD->bTotalSize = 0;
  710. }
  711. }
  712. if (pstD->bElapsedTime)
  713. {
  714. hwnd = GetDlgItem(pstL->hDlg, XFR_ELAPSED_BOX);
  715. if (hwnd)
  716. {
  717. wsprintf(acBuffer,
  718. " %02d:%02d:%02d",
  719. (USHORT)(pstD->lElapsedTime / 3600),
  720. (USHORT)((pstD->lElapsedTime / 60) % 60),
  721. (USHORT)(pstD->lElapsedTime % 60)
  722. );
  723. SetWindowText(hwnd, acBuffer);
  724. pstD->bElapsedTime = 0;
  725. }
  726. }
  727. if (pstD->bRemainingTime)
  728. {
  729. hwnd = GetDlgItem(pstL->hDlg, XFR_REMAINING_BOX);
  730. if (hwnd)
  731. {
  732. if (pstD->lRemainingTime < 0)
  733. pstD->lRemainingTime = 0;
  734. wsprintf(acBuffer,
  735. " %02d:%02d:%02d",
  736. (USHORT)(pstD->lRemainingTime / 3600),
  737. (USHORT)((pstD->lRemainingTime / 60) % 60),
  738. (USHORT)(pstD->lRemainingTime % 60)
  739. );
  740. SetWindowText(hwnd, acBuffer);
  741. pstD->bRemainingTime = 0;
  742. }
  743. }
  744. if (pstD->bThroughput)
  745. {
  746. hwnd = GetDlgItem(pstL->hDlg, XFR_THRUPUT_BOX);
  747. if (hwnd)
  748. {
  749. int nValue;
  750. TCHAR acMsg[64];
  751. LoadString(glblQueryDllHinst(),
  752. xfrGetXferDspBps(sessQueryXferHdl(pstL->hSession)) ?
  753. IDS_XD_BPS : IDS_XD_CPS,
  754. acMsg,
  755. sizeof(acMsg) / sizeof(TCHAR));
  756. nValue = pstD->lThroughput;
  757. if (xfrGetXferDspBps(sessQueryXferHdl(pstL->hSession)))
  758. nValue *= 10;
  759. wsprintf(acBuffer, acMsg, nValue);
  760. SetWindowText(hwnd, acBuffer);
  761. pstD->bThroughput = 0;
  762. }
  763. }
  764. if (pstD->bLastErrtype)
  765. {
  766. hwnd = GetDlgItem(pstL->hDlg, XFR_LAST_ERROR_BOX);
  767. if (hwnd)
  768. {
  769. TCHAR acMsg[64];
  770. LoadString(glblQueryDllHinst(),
  771. xfrGetStatusBase(sessQueryXferHdl(pstL->hSession))
  772. + pstD->wLastErrtype,
  773. acMsg,
  774. sizeof(acMsg) / sizeof(TCHAR));
  775. SetWindowText(hwnd, acMsg);
  776. pstD->bLastErrtype = 0;
  777. }
  778. }
  779. if (pstD->bPcktErrCnt)
  780. {
  781. hwnd = GetDlgItem(pstL->hDlg, XFR_PACKET_RETRY_BOX);
  782. if (hwnd)
  783. {
  784. TCHAR acMsg[64];
  785. LoadString(glblQueryDllHinst(),
  786. IDS_XD_INT,
  787. acMsg,
  788. sizeof(acMsg) / sizeof(TCHAR));
  789. wsprintf(acBuffer,
  790. acMsg,
  791. pstD->wPcktErrCnt);
  792. SetWindowText(hwnd, acBuffer);
  793. pstD->bPcktErrCnt = 0;
  794. }
  795. }
  796. if (pstD->bChecktype)
  797. {
  798. int nTag;
  799. TCHAR acMsg[64];
  800. hwnd = GetDlgItem(pstL->hDlg, XFR_ERROR_CHECKING_BOX);
  801. if (hwnd)
  802. {
  803. switch (pstD->wChecktype)
  804. {
  805. default:
  806. case 0:
  807. nTag = IDS_XD_CRC;
  808. break;
  809. case 1:
  810. nTag = IDS_XD_CHECK;
  811. break;
  812. case 2:
  813. nTag = IDS_XD_STREAM;
  814. break;
  815. }
  816. LoadString(glblQueryDllHinst(),
  817. nTag,
  818. acMsg,
  819. sizeof(acMsg) / sizeof(TCHAR));
  820. SetWindowText(hwnd, acMsg);
  821. pstD->bChecktype = 0;
  822. }
  823. }
  824. if (pstD->bProtocol)
  825. {
  826. int nTag;
  827. TCHAR acMsg[64];
  828. hwnd = GetDlgItem(pstL->hDlg, XFR_PROTOCOL_BOX);
  829. if (hwnd)
  830. {
  831. switch (pstD->uProtocol)
  832. {
  833. default:
  834. case 1:
  835. nTag = IDS_XD_CB;
  836. break;
  837. case 2:
  838. nTag = IDS_XD_BP;
  839. break;
  840. }
  841. LoadString(glblQueryDllHinst(),
  842. nTag,
  843. acMsg,
  844. sizeof(acMsg) / sizeof(TCHAR));
  845. SetWindowText(hwnd, acMsg);
  846. pstD->bProtocol = 0;
  847. }
  848. }
  849. if (pstD->bMessage)
  850. {
  851. hwnd = GetDlgItem(pstL->hDlg, XFR_MESSAGE_BOX);
  852. if (hwnd)
  853. {
  854. SetWindowText(hwnd, pstD->acMessage);
  855. pstD->bMessage = 0;
  856. }
  857. }
  858. if (pstD->nClose)
  859. {
  860. HWND hWnd;
  861. /* It's time to quit */
  862. xfrSetPercentDone(sessQueryXferHdl(pstL->hSession), 0);
  863. // We decided that the new way might be a bit safer
  864. // EndModelessDialog(pstD->hwndXfrDisplay);
  865. hWnd = pstD->hwndXfrDisplay;
  866. pstD->hwndXfrDisplay = (HWND)0;
  867. PostMessage(sessQueryHwnd(pstL->hSession),
  868. WM_SESS_ENDDLG,
  869. 0, (LPARAM)hWnd);
  870. }
  871. }