Source code of Windows XP (NT5)
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.

350 lines
10 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOLSTRING TRUE /* jtf win3 mod */
  6. #include <windows.h>
  7. #include "port1632.h"
  8. #include "dcrc.h"
  9. #include "dynacomm.h"
  10. #include "video.h"
  11. /*---------------------------------------------------------------------------*/
  12. /* showXferCtrls() - [mbb] */
  13. /*---------------------------------------------------------------------------*/
  14. VOID setXferCtrlButton(WORD wCtrlID, WORD wResID) /* mbbx 2.00: xfer ctrls... */
  15. //WORD wCtrlID;
  16. //WORD wResID;
  17. {
  18. BYTE work[MINRESSTR];
  19. LoadString(hInst, wResID, (LPSTR) work, MINRESSTR);
  20. SetWindowText(GetDlgItem(hdbXferCtrls, wCtrlID), (LPSTR) work);
  21. }
  22. INT NEAR placeXferCtrl(HWND hCtrl, INT fCtrlLeft)
  23. {
  24. RECT fCtrlRect;
  25. GetWindowRect(hCtrl, (LPRECT) &fCtrlRect);
  26. fCtrlRect.right -= fCtrlRect.left;
  27. MoveWindow(hCtrl, fCtrlLeft, 0, fCtrlRect.right, fCtrlRect.bottom - fCtrlRect.top, FALSE);
  28. return(fCtrlLeft + fCtrlRect.right);
  29. }
  30. VOID showXferCtrls(WORD fShowCtrls) /* mbbx 2.00: xfer ctrls... */
  31. //WORD fShowCtrls;
  32. {
  33. INT fCtrlLeft;
  34. //sdj: the status line does not get updates when you come back
  35. //sdj: to terminal focus.
  36. if (hdbmyControls != NULL)
  37. {
  38. if(IsWindowVisible(hdbmyControls))
  39. {
  40. InvalidateRect(hdbmyControls, NULL, FALSE);
  41. UpdateWindow(hdbmyControls);
  42. }
  43. }
  44. if(fShowCtrls)
  45. {
  46. fCtrlLeft = placeXferCtrl(xferCtlStop, 0);
  47. if(fShowCtrls & IDPAUSE)
  48. {
  49. fCtrlLeft = placeXferCtrl(xferCtlPause, fCtrlLeft);
  50. }
  51. if(fShowCtrls & IDFORK)
  52. {
  53. fCtrlLeft = placeXferCtrl(GetDlgItem(hdbXferCtrls, IDFORK), fCtrlLeft);
  54. }
  55. fCtrlLeft = placeXferCtrl(xferCtlScale, fCtrlLeft);
  56. fCtrlLeft = placeXferCtrl(GetDlgItem(hdbXferCtrls, IDSENDING), fCtrlLeft);
  57. if(fShowCtrls & IDBERRORS)
  58. {
  59. fCtrlLeft = placeXferCtrl(GetDlgItem(hdbXferCtrls, IDBERRORS), fCtrlLeft);
  60. }
  61. ShowWindow(hdbXferCtrls, SW_SHOWNOACTIVATE);
  62. if(fShowCtrls & IDPAUSE)
  63. {
  64. ShowWindow(xferCtlPause, SW_SHOWNOACTIVATE);
  65. }
  66. if(fShowCtrls & IDFORK)
  67. {
  68. #ifdef ORGCODE
  69. bSetUp(SPACE_STR+1);
  70. #else
  71. bSetup(SPACE_STR+1);
  72. #endif
  73. }
  74. if(fShowCtrls & IDSCALE)
  75. showScale();
  76. else
  77. showBBytes(0L, TRUE);
  78. if(fShowCtrls & IDBERRORS)
  79. {
  80. showBErrors(0);
  81. }
  82. }
  83. else
  84. {
  85. ShowWindow(hdbXferCtrls, SW_HIDE);
  86. ShowWindow(xferCtlPause, SW_HIDE);
  87. ShowWindow(GetDlgItem(hdbXferCtrls, IDFORK), SW_HIDE);
  88. ShowWindow(GetDlgItem(hdbXferCtrls, IDBERRORS), SW_HIDE);
  89. }
  90. }
  91. /*---------------------------------------------------------------------------*/
  92. /* setItemText() - Set the text of a dialog item */
  93. /*---------------------------------------------------------------------------*/
  94. HDC NEAR beginXferCtrlUpdate(HWND hCtrl, RECT *ctrlRect, BOOL bRepaint)
  95. {
  96. HDC hDC;
  97. HBRUSH hBrush;
  98. hDC = GetDC(hCtrl);
  99. GetClientRect(hCtrl, (LPRECT) ctrlRect);
  100. if(bRepaint)
  101. FillRect(hDC, (LPRECT) ctrlRect, (HBRUSH) GetStockObject(GRAY_BRUSH));
  102. InflateRect((LPRECT) ctrlRect, -1, -1);
  103. if(bRepaint)
  104. {
  105. hBrush = CreateSolidBrush(RGB(vidAttr[ANORMAL & AMASK].bkgd[VID_RED],
  106. vidAttr[ANORMAL & AMASK].bkgd[VID_GREEN],
  107. vidAttr[ANORMAL & AMASK].bkgd[VID_BLUE]));
  108. FillRect(hDC, (LPRECT) ctrlRect, hBrush);
  109. DeleteObject(hBrush);
  110. FrameRect(hDC, (LPRECT) ctrlRect, (HBRUSH) GetStockObject(BLACK_BRUSH));
  111. }
  112. return(hDC);
  113. }
  114. VOID NEAR setItemText(INT item, BYTE *str, BOOL bRepaint)
  115. {
  116. HWND hItem;
  117. HDC hDC;
  118. RECT rect;
  119. hItem = GetDlgItem(hdbXferCtrls, item);
  120. if(bRepaint)
  121. {
  122. UpdateWindow(hdbXferCtrls);
  123. if(!IsWindowVisible(hItem))
  124. ShowWindow(hItem, SW_SHOWNOACTIVATE);
  125. }
  126. hDC = beginXferCtrlUpdate(hItem, &rect, bRepaint);
  127. InflateRect((LPRECT) &rect, -4, -1);
  128. SetBkColor(hDC, RGB(vidAttr[ANORMAL & AMASK].bkgd[VID_RED],
  129. vidAttr[ANORMAL & AMASK].bkgd[VID_GREEN],
  130. vidAttr[ANORMAL & AMASK].bkgd[VID_BLUE]));
  131. SetTextColor(hDC, RGB(vidAttr[ANORMAL & AMASK].text[VID_RED],
  132. vidAttr[ANORMAL & AMASK].text[VID_GREEN],
  133. vidAttr[ANORMAL & AMASK].text[VID_BLUE]));
  134. DrawText(hDC, (LPSTR) str, strlen(str), (LPRECT) &rect, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
  135. ReleaseDC(hItem, hDC);
  136. }
  137. /*---------------------------------------------------------------------------*/
  138. /* bSetUp() - [mbb] */
  139. /*---------------------------------------------------------------------------*/
  140. VOID bSetup(BYTE *str) /* mbbx 2.00: moved from XFERUTIL.C ... */
  141. {
  142. setItemText(IDFORK, str, TRUE);
  143. strcpy(strRXFork, str);
  144. }
  145. /*---------------------------------------------------------------------------*/
  146. /* showScale() - Draw the % done scale for file transfers. [scf] */
  147. /*---------------------------------------------------------------------------*/
  148. #define SECTIONS 10
  149. #define TICKWIDTH 2
  150. VOID showScale() /* mbbx 2.00: xfer ctrls... */
  151. {
  152. HDC hDC;
  153. RECT rBase, rect;
  154. INT increment, error, tickHeight, ndx, offset;
  155. HBRUSH hBrush;
  156. *strRXBytes = 255; /* IDSCALE is scale, not bytes count */
  157. UpdateWindow(hdbXferCtrls);
  158. hDC = beginXferCtrlUpdate(xferCtlScale, &rBase, TRUE); /* mbbx 2.00: xfer ctrls... */
  159. InflateRect((LPRECT) &rBase, -1, -1);
  160. increment = rBase.right / SECTIONS;
  161. error = rBase.right - (increment * SECTIONS);
  162. tickHeight = rBase.bottom / 2;
  163. hBrush = CreateSolidBrush(RGB(vidAttr[ANORMAL & AMASK].text[VID_RED],
  164. vidAttr[ANORMAL & AMASK].text[VID_GREEN],
  165. vidAttr[ANORMAL & AMASK].text[VID_BLUE]));
  166. for(ndx = 1; ndx < SECTIONS; ndx += 1)
  167. {
  168. offset = (ndx * increment) + ((ndx * error) / SECTIONS);
  169. SetRect((LPRECT) &rect, (rBase.left + offset) - TICKWIDTH,
  170. (ndx != SECTIONS / 2) ? tickHeight : tickHeight - (tickHeight / 2),
  171. (rBase.left + offset) + TICKWIDTH, rBase.bottom);
  172. FillRect(hDC, (LPRECT) &rect, hBrush);
  173. }
  174. DeleteObject(hBrush);
  175. ReleaseDC(xferCtlScale, hDC);
  176. }
  177. /*---------------------------------------------------------------------------*/
  178. /* updateProgress() Update the scale (thermometer) for xfers */
  179. /*---------------------------------------------------------------------------*/
  180. VOID updateProgress(BOOL redraw)
  181. {
  182. HDC hDC;
  183. RECT ctrlRect;
  184. INT left, right;
  185. if(redraw)
  186. {
  187. xferPct = 0;
  188. icon.last = 0;
  189. if(IsIconic(hItWnd))
  190. {
  191. myDrawIcon(getPort(), TRUE);
  192. releasePort();
  193. }
  194. else
  195. showScale();
  196. }
  197. progress = 256 - (xferBytes * 256) / (xferOrig ? xferOrig : 1); /* avoid div by zero */
  198. if(IsIconic(hItWnd))
  199. updateIcon();
  200. else
  201. {
  202. if(progress > xferPct)
  203. {
  204. hDC = GetDC(xferCtlScale);
  205. GetClientRect(xferCtlScale, (LPRECT) &ctrlRect);
  206. InflateRect((LPRECT) &ctrlRect, -2, -2); /* mbbx 2.00: xfer ctrls... */
  207. ctrlRect.right -= ctrlRect.left;
  208. left = (INT) (((LONG) xferPct * (LONG) ctrlRect.right) / 256);
  209. right = (INT) (((LONG) progress * (LONG) ctrlRect.right) / 256);
  210. ctrlRect.right = ctrlRect.left + (INT) right;
  211. ctrlRect.left += (INT) left;
  212. InvertRect(hDC, (LPRECT) &ctrlRect);
  213. ReleaseDC(xferCtlScale, hDC);
  214. }
  215. }
  216. if(progress > xferPct)
  217. xferPct = progress;
  218. }
  219. /*---------------------------------------------------------------------------*/
  220. /* showBBytes() - [mbb] */
  221. /*---------------------------------------------------------------------------*/
  222. VOID showBBytes(LONG cnt, BOOL bRepaint)
  223. {
  224. BYTE tmp1[TMPNSTR+1];
  225. BYTE tmp2[TMPNSTR+1];
  226. LoadString(hInst, STR_BYTECOUNT, (LPSTR) tmp1, TMPNSTR);
  227. sprintf(tmp2, tmp1, cnt);
  228. setItemText(IDSCALE, tmp2, bRepaint);
  229. strcpy(strRXBytes, tmp2);
  230. }
  231. /*---------------------------------------------------------------------------*/
  232. /* showRXFname() - */
  233. /*---------------------------------------------------------------------------*/
  234. VOID showRXFname(BYTE *fileName, INT actionString)
  235. {
  236. BYTE tmp1[TMPNSTR+1];
  237. LoadString(hInst, actionString, (LPSTR) tmp1, TMPNSTR);
  238. strcpy(tmp1+strlen(tmp1), fileName);
  239. setItemText(IDSENDING, tmp1, TRUE); /* mbbx 2.00: xfer ctrls */
  240. strcpy(strRXFname, tmp1);
  241. }
  242. /*---------------------------------------------------------------------------*/
  243. /* showBErrors() - [scf] */
  244. /*---------------------------------------------------------------------------*/
  245. VOID showBErrors(INT cnt)
  246. {
  247. BYTE tmp1[TMPNSTR+1];
  248. BYTE tmp2[TMPNSTR+1];
  249. LoadString(hInst, STR_RETRIES, (LPSTR) tmp1, TMPNSTR); /* mbbx 1.00 ... */
  250. sprintf(tmp2, tmp1, cnt);
  251. setItemText(IDBERRORS, tmp2, TRUE); /* mbbx 2.00: xfer ctrls */
  252. strcpy(strRXErrors, tmp2);
  253. }
  254. /*---------------------------------------------------------------------------*/
  255. /* updateIndicators() - */
  256. /*---------------------------------------------------------------------------*/
  257. VOID updateIndicators() /* mbbx 2.00: moved from DCUTIL2.C ... */
  258. {
  259. if(xferFlag != XFRNONE)
  260. {
  261. UpdateWindow(hdbXferCtrls); /* mbbx 1.04: fkeys... */
  262. if(*strRXFork != 0)
  263. setItemText(IDFORK, strRXFork, TRUE); /* mbbx 2.00: xfer ctrls... */
  264. if(*strRXBytes == 255)
  265. updateProgress(TRUE);
  266. else if(*strRXBytes != 0)
  267. setItemText(IDSCALE, strRXBytes, TRUE);
  268. if(*strRXFname != 0)
  269. setItemText(IDSENDING, strRXFname, TRUE);
  270. if(*strRXErrors != 0)
  271. setItemText(IDBERRORS, strRXErrors, TRUE);
  272. }
  273. }