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.

267 lines
5.7 KiB

  1. /* File: C:\WACKER\xfer\x_kr_dlg.c (Created: 27-Jan-1994)
  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,1993,1994 by Hilgraeve Inc. -- Monroe, MI
  8. * All rights reserved
  9. *
  10. * $Revision: 3 $
  11. * $Date: 5/15/02 4:41p $
  12. */
  13. #include <windows.h>
  14. #pragma hdrstop
  15. #include <commctrl.h>
  16. #include <tdll\stdtyp.h>
  17. #include <tdll\mc.h>
  18. #include <tdll\assert.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 CMP_CHECK 102
  33. #define BPP_UDC 104
  34. #define SWP_UDC 106
  35. #define ECS_UDC 108
  36. #define RTY_UDC 110
  37. #define PSC_UDC 112
  38. #define PEC_UDC 114
  39. #define NPD_UDC 116
  40. #define PDC_UDC 118
  41. struct stUpDownControls
  42. {
  43. int nId;
  44. int nMin;
  45. int nMax;
  46. int nDef;
  47. };
  48. typedef struct stUpDownControls UDC;
  49. #if defined(UPPER_FEATURES)
  50. UDC aUDC[10] =
  51. {
  52. {BPP_UDC, 20, 94, 94},
  53. {SWP_UDC, 5, 60, 5},
  54. {ECS_UDC, 1, 3, 1},
  55. {RTY_UDC, 1, 25, 5},
  56. {PSC_UDC, 0, 255, 1},
  57. {PEC_UDC, 0, 255, 13},
  58. {NPD_UDC, 0, 99, 0},
  59. {PDC_UDC, 0, 255, 0},
  60. {0, 0, 0, 0}
  61. };
  62. #endif
  63. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  64. * FUNCTION:
  65. * KermitParamsDlg
  66. *
  67. * DESCRIPTION:
  68. * The dialog proc for changing Kermit parameters.
  69. *
  70. * ARGUMENTS:
  71. * Standard Windows dialog manager parameters
  72. *
  73. * RETURNS:
  74. * Standard Windows dialog manager
  75. *
  76. */
  77. BOOL CALLBACK KermitParamsDlg(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  78. {
  79. #if defined(UPPER_FEATURES)
  80. HWND hwndChild;
  81. INT nId;
  82. INT nNtfy;
  83. SDS *pS;
  84. XFR_KR_PARAMS *pK;
  85. switch (wMsg)
  86. {
  87. case WM_INITDIALOG:
  88. pS = (SDS *)malloc(sizeof(SDS));
  89. if (pS == (SDS *)0)
  90. {
  91. /* TODO: decide if we need to display an error here */
  92. EndDialog(hDlg, FALSE);
  93. }
  94. pS->lPar = lPar; /* Save for later use */
  95. pK = (XFR_KR_PARAMS *)lPar; /* We also need it for now */
  96. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pS);
  97. /*
  98. * Build the Up/Down controls
  99. */
  100. for (nId = 0; nId < 10; nId += 1)
  101. {
  102. RECT rc;
  103. HWND hwndTmp;
  104. DWORD dw;
  105. int nWide;
  106. if (aUDC[nId].nId != 0)
  107. {
  108. GetClientRect(GetDlgItem(hDlg, aUDC[nId].nId), &rc);
  109. nWide = rc.top - rc.bottom;
  110. dw = WS_CHILD | WS_BORDER | WS_VISIBLE;
  111. dw |= UDS_ALIGNRIGHT;
  112. dw |= UDS_ARROWKEYS;
  113. dw |= UDS_SETBUDDYINT;
  114. hwndTmp = CreateUpDownControl(
  115. dw, /* create window flags */
  116. rc.right, /* left edge */
  117. rc.top, /* top edge */
  118. (nWide / 3) * 2,/* width */
  119. nWide, /* height */
  120. hDlg, /* parent window */
  121. aUDC[nId].nId + 100,
  122. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  123. GetDlgItem(hDlg, aUDC[nId].nId),
  124. aUDC[nId].nMax, /* upper limit */
  125. aUDC[nId].nMin, /* lower limit */
  126. aUDC[nId].nDef);/* starting position */
  127. assert(hwndTmp);
  128. }
  129. }
  130. /*
  131. * Set the controls to the correct values
  132. */
  133. SetDlgItemInt(hDlg, BPP_UDC, pK->nBytesPerPacket, FALSE);
  134. SetDlgItemInt(hDlg, SWP_UDC, pK->nSecondsWaitPacket, FALSE);
  135. SetDlgItemInt(hDlg, ECS_UDC, pK->nErrorCheckSize, FALSE);
  136. SetDlgItemInt(hDlg, RTY_UDC, pK->nRetryCount, FALSE);
  137. SetDlgItemInt(hDlg, PSC_UDC, pK->nPacketStartChar, FALSE);
  138. SetDlgItemInt(hDlg, PEC_UDC, pK->nPacketEndChar, FALSE);
  139. SetDlgItemInt(hDlg, NPD_UDC, pK->nNumberPadChars, FALSE);
  140. SetDlgItemInt(hDlg, PDC_UDC, pK->nPadChar, FALSE);
  141. break;
  142. case WM_DESTROY:
  143. break;
  144. case WM_COMMAND:
  145. /*
  146. * Did we plan to put a macro in here to do the parsing ?
  147. */
  148. DlgParseCmd(nId, nNtfy, hwndChild, wPar, lPar);
  149. switch (nId)
  150. {
  151. case IDOK:
  152. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  153. if (pS)
  154. {
  155. /*
  156. * Do whatever saving is necessary
  157. */
  158. pK = (XFR_KR_PARAMS *)pS->lPar;
  159. if (pK)
  160. {
  161. BOOL nTranslated = FALSE;
  162. int nVal = 0;
  163. nVal = GetDlgItemInt(hDlg, BPP_UDC, &nTranslated, TRUE);
  164. if (nTranslated)
  165. {
  166. pK->nBytesPerPacket = nVal;
  167. }
  168. nVal = GetDlgItemInt(hDlg, SWP_UDC, &nTranslated, TRUE);
  169. if (nTranslated)
  170. {
  171. pK->nSecondsWaitPacket = nVal;
  172. }
  173. nVal = GetDlgItemInt(hDlg, ECS_UDC, &nTranslated, TRUE);
  174. if (nTranslated)
  175. {
  176. pK->nErrorCheckSize = nVal;
  177. }
  178. nVal = GetDlgItemInt(hDlg, RTY_UDC, &nTranslated, TRUE);
  179. if (nTranslated)
  180. {
  181. pK->nRetryCount = nVal;
  182. }
  183. nVal = GetDlgItemInt(hDlg, PSC_UDC, &nTranslated, TRUE);
  184. if (nTranslated)
  185. {
  186. pK->nPacketStartChar = nVal;
  187. }
  188. nVal = GetDlgItemInt(hDlg, PEC_UDC, &nTranslated, TRUE);
  189. if (nTranslated)
  190. {
  191. pK->nPacketEndChar = nVAl;
  192. }
  193. nVal = GetDlgItemInt(hDlg, NPD_UDC, &nTranslated, TRUE);
  194. if (nTranslated)
  195. {
  196. pK->nNumberPadChars = nVal;
  197. }
  198. nVal = GetDlgItemInt(hDlg, PDC_UDC, &nTranslated, TRUE);
  199. if (nTranslated)
  200. {
  201. pK->nPadChar = nVal;
  202. }
  203. }
  204. /* Free the storeage */
  205. free(pS);
  206. pS = (SDS *)0;
  207. }
  208. EndDialog(hDlg, TRUE);
  209. break;
  210. case IDCANCEL:
  211. pS = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  212. /* Free the storeage */
  213. free(pS);
  214. pS = (SDS *)0;
  215. EndDialog(hDlg, FALSE);
  216. break;
  217. default:
  218. return FALSE;
  219. }
  220. break;
  221. default:
  222. return FALSE;
  223. }
  224. #endif
  225. return TRUE;
  226. }