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.

301 lines
6.7 KiB

  1. /* File: C:\WACKER\xfer\x_xy_dlg.c (Created: 17-Jan-1993)
  2. * created from:
  3. * File: C:\WACKER\TDLL\genrcdlg.c (Created: 16-Dec-1993)
  4. * created from:
  5. * File: C:\HA5G\ha5g\genrcdlg.c (Created: 12-Sep-1990)
  6. *
  7. * Copyright 1990,1994 by Hilgraeve Inc. -- Monroe, MI
  8. * All rights reserved
  9. *
  10. * $Revision: 4 $
  11. * $Date: 7/12/02 8:19a $
  12. */
  13. #include <windows.h>
  14. #pragma hdrstop
  15. #include <commctrl.h>
  16. #include <tdll\stdtyp.h>
  17. #include <tdll\assert.h>
  18. #include <tdll\mc.h>
  19. #include "xfer.h"
  20. #include "xfer.hh"
  21. #if !defined(DlgParseCmd)
  22. #define DlgParseCmd(i,n,c,w,l) i=LOWORD(w);n=HIWORD(w);c=(HWND)l;
  23. #endif
  24. struct stSaveDlgStuff
  25. {
  26. /*
  27. * Put in whatever else you might need to access later
  28. */
  29. LPARAM lPar;
  30. };
  31. typedef struct stSaveDlgStuff SDS;
  32. #define AUTO_ERRCHK 101
  33. #define CRC_ERRCHK 102
  34. #define CSUM_ERRCHK 103
  35. #define CMPRS_ON 105
  36. #define CMPRS_OFF 106
  37. #define BYTE_SECONDS 110
  38. #define PACKET_WAIT 112
  39. #define PACKET_SECONDS 108
  40. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  41. * FUNCTION: Generic Dialog
  42. *
  43. * DESCRIPTION: Dialog manager stub
  44. *
  45. * ARGUMENTS: Standard Windows dialog manager
  46. *
  47. * RETURNS: Standard Windows dialog manager
  48. *
  49. */
  50. BOOL CALLBACK XandYmodemParamsDlg(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  51. {
  52. #if defined(UPPER_FEATURES)
  53. HWND hwndChild;
  54. INT nId;
  55. INT nNtfy;
  56. SDS *pS;
  57. XFR_XY_PARAMS *pP;
  58. switch (wMsg)
  59. {
  60. case WM_INITDIALOG:
  61. {
  62. RECT rc;
  63. DWORD dw;
  64. int nSize;
  65. HWND hwndUpDown;
  66. HWND hwndCtl;
  67. pS = (SDS *)malloc(sizeof(SDS));
  68. if (pS == (SDS *)0)
  69. {
  70. /* TODO: decide if we need to display an error here */
  71. EndDialog(hDlg, FALSE);
  72. }
  73. pS->lPar = lPar;
  74. pP = (XFR_XY_PARAMS *)lPar;
  75. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pS);
  76. hwndCtl = GetDlgItem(hDlg, AUTO_ERRCHK);
  77. if (hwndCtl)
  78. {
  79. switch(pP->nErrCheckType)
  80. {
  81. case XP_ECP_CRC:
  82. nSize = CRC_ERRCHK;
  83. break;
  84. case XP_ECP_CHECKSUM:
  85. nSize = CSUM_ERRCHK;
  86. break;
  87. case XP_ECP_AUTOMATIC:
  88. default:
  89. nSize = AUTO_ERRCHK;
  90. break;
  91. }
  92. SendMessage(GetDlgItem(hDlg, nSize),
  93. BM_SETCHECK, TRUE, 0L);
  94. }
  95. hwndCtl = GetDlgItem(hDlg, CMPRS_ON);
  96. if (hwndCtl)
  97. {
  98. nSize = CMPRS_OFF;
  99. SendMessage(GetDlgItem(hDlg, nSize),
  100. BM_SETCHECK, TRUE, 0L);
  101. }
  102. GetClientRect(GetDlgItem(hDlg, PACKET_SECONDS), &rc);
  103. nSize = rc.top - rc.bottom;
  104. dw = WS_CHILD | WS_BORDER | WS_VISIBLE;
  105. dw |= UDS_ALIGNRIGHT;
  106. dw |= UDS_ARROWKEYS;
  107. dw |= UDS_SETBUDDYINT;
  108. hwndUpDown = CreateUpDownControl(
  109. dw, /* create window flags */
  110. rc.right, /* left edge */
  111. rc.top, /* top edge */
  112. (nSize / 3) * 2,/* width */
  113. nSize, /* height */
  114. hDlg, /* parent window */
  115. PACKET_SECONDS + 1,
  116. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  117. GetDlgItem(hDlg, PACKET_SECONDS),
  118. 60, /* upper limit */
  119. 1, /* lower limit */
  120. pP->nPacketWait);/* starting position */
  121. assert(hwndUpDown);
  122. GetClientRect(GetDlgItem(hDlg, BYTE_SECONDS), &rc);
  123. nSize = rc.top - rc.bottom;
  124. dw = WS_CHILD | WS_BORDER | WS_VISIBLE;
  125. dw |= UDS_ALIGNRIGHT;
  126. dw |= UDS_ARROWKEYS;
  127. dw |= UDS_SETBUDDYINT;
  128. hwndUpDown = CreateUpDownControl(
  129. dw, /* create window flags */
  130. rc.right, /* left edge */
  131. rc.top, /* top edge */
  132. (nSize / 3) * 2,/* width */
  133. nSize, /* height */
  134. hDlg, /* parent window */
  135. BYTE_SECONDS + 1,
  136. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  137. GetDlgItem(hDlg, BYTE_SECONDS),
  138. 60, /* upper limit */
  139. 1, /* lower limit */
  140. pP->nByteWait);/* starting position */
  141. assert(hwndUpDown);
  142. GetClientRect(GetDlgItem(hDlg, PACKET_WAIT), &rc);
  143. nSize = rc.top - rc.bottom;
  144. dw = WS_CHILD | WS_BORDER | WS_VISIBLE;
  145. dw |= UDS_ALIGNRIGHT;
  146. dw |= UDS_ARROWKEYS;
  147. dw |= UDS_SETBUDDYINT;
  148. hwndUpDown = CreateUpDownControl(
  149. dw, /* create window flags */
  150. rc.right, /* left edge */
  151. rc.top, /* top edge */
  152. (nSize / 3) * 2,/* width */
  153. nSize, /* height */
  154. hDlg, /* parent window */
  155. PACKET_WAIT + 1,
  156. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  157. GetDlgItem(hDlg, PACKET_WAIT),
  158. 25, /* upper limit */
  159. 1, /* lower limit */
  160. pP->nNumRetries);/* starting position */
  161. assert(hwndUpDown);
  162. }
  163. break;
  164. case WM_DESTROY:
  165. break;
  166. case WM_COMMAND:
  167. /*
  168. * Did we plan to put a macro in here to do the parsing ?
  169. */
  170. DlgParseCmd(nId, nNtfy, hwndChild, wPar, lPar);
  171. switch (nId)
  172. {
  173. case IDOK:
  174. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  175. if (pS)
  176. {
  177. /*
  178. * Do whatever saving is necessary
  179. */
  180. pP = (XFR_XY_PARAMS *)pS->lPar;
  181. if (pP)
  182. {
  183. BOOL nTranslated = FALSE;
  184. int nVal;
  185. nVal = XP_ECP_AUTOMATIC;
  186. if (GetDlgItem(hDlg, AUTO_ERRCHK))
  187. {
  188. if (IsDlgButtonChecked(hDlg, AUTO_ERRCHK) == BST_CHECKED)
  189. {
  190. nVal = XP_ECP_AUTOMATIC;
  191. }
  192. else if (IsDlgButtonChecked(hDlg, CRC_ERRCHK) == BST_CHECKED)
  193. {
  194. nVal = XP_ECP_CRC;
  195. }
  196. else if (IsDlgButtonChecked(hDlg, CSUM_ERRCHK) == BST_CHECKED)
  197. {
  198. nVal = XP_ECP_CHECKSUM;
  199. }
  200. }
  201. pP->nErrCheckType = nVal;
  202. // TODO If we add compression, then add option here.
  203. //
  204. nTranslated = TRUE;
  205. if (GetDlgItem(hDlg, CMPRS_ON))
  206. {
  207. nTranslated = (IsDlgButtonChecked(hDlg, CMPRS_ON) == BST_CHECKED)
  208. }
  209. //pP->? = nVal;
  210. nVal = GetDlgItemInt(hDlg, PACKET_SECONDS, &nTranslated, TRUE);
  211. if (nTranslated && (nVal < 0 || nVal > 60))
  212. {
  213. nVal = 20;
  214. }
  215. pP->nPacketWait = nVal;
  216. nVal = GetDlgItemInt(hDlg, BYTE_SECONDS, &nTranslated, TRUE);
  217. if (nTranslated && (nVal < 0 || nVal > 60)))
  218. {
  219. nVal = 5;
  220. }
  221. pP->nByteWait = nVal;
  222. nVal = GetDlgItemInt(hDlg, PACKET_WAIT, &nTranslated, TRUE);
  223. if (nTranslated && (nVal < 0 || nVal > 25)))
  224. {
  225. nVal = 10;
  226. }
  227. pP->nNumRetries = nVal;
  228. }
  229. else
  230. {
  231. assert(FALSE);
  232. MessageBox(hDlg, "Invalid transfer protocol", NULL, MB_OK);
  233. }
  234. /* Free the storeage */
  235. free(pS);
  236. pS = (SDS *)0;
  237. }
  238. EndDialog(hDlg, TRUE);
  239. break;
  240. case IDCANCEL:
  241. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  242. /* Free the storeage */
  243. free(pS);
  244. pS = (SDS *)0;
  245. EndDialog(hDlg, FALSE);
  246. break;
  247. default:
  248. return FALSE;
  249. }
  250. break;
  251. default:
  252. return FALSE;
  253. }
  254. #endif
  255. return TRUE;
  256. }