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.

251 lines
6.6 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include <assert.h>
  3. #include "precomp.h"
  4. static int iDeleteKeyStatus = 0;
  5. void SetDeleteKeyStatus(int iValue)
  6. {
  7. iDeleteKeyStatus = iValue;
  8. }
  9. int GetDeleteKeyStatus(void)
  10. {
  11. return iDeleteKeyStatus ;
  12. }
  13. void MoveCaret(int nID, HWND hwnd )
  14. {
  15. POINT Pt;
  16. int iCaretIndex ;
  17. DWORD dwNext = 0;
  18. TCHAR tcUserValue[ CHARS_IN_BATCH + 1];
  19. DWORD dwLen ;
  20. GetCaretPos(&Pt);
  21. iCaretIndex = (int) SendMessage(GetDlgItem(hwnd,nID), EM_CHARFROMPOS, 0, MAKELPARAM(Pt.x, Pt.y));
  22. GetDlgItemText(hwnd,nID, tcUserValue, CHARS_IN_BATCH+1);
  23. dwLen = _tcslen(tcUserValue);
  24. switch(iCaretIndex)
  25. {
  26. case 0: //Move to left edit box
  27. dwNext = -1 ;
  28. switch(nID)
  29. {
  30. case IDC_TXT_TELEINFO2:
  31. dwNext = IDC_TXT_TELEINFO1;
  32. break ;
  33. case IDC_TXT_TELEINFO3:
  34. dwNext = IDC_TXT_TELEINFO2;
  35. break ;
  36. case IDC_TXT_TELEINFO4:
  37. dwNext = IDC_TXT_TELEINFO3;
  38. break ;
  39. case IDC_TXT_TELEINFO5:
  40. dwNext = IDC_TXT_TELEINFO4;
  41. break ;
  42. case IDC_TXT_TELEINFO6:
  43. dwNext = IDC_TXT_TELEINFO5;
  44. break ;
  45. case IDC_TXT_TELEINFO7:
  46. dwNext = IDC_TXT_TELEINFO6;
  47. break ;
  48. }
  49. if (dwNext != -1 && dwLen == 0 && GetDeleteKeyStatus() == 0)
  50. {
  51. SetFocus(GetDlgItem(hwnd, dwNext));
  52. SendMessage(GetDlgItem(hwnd,dwNext),WM_KEYDOWN, VK_END,0);
  53. }
  54. break;
  55. case 5: //Move to right edit box
  56. dwNext = -1 ;
  57. switch(nID)
  58. {
  59. case IDC_TXT_TELEINFO1:
  60. dwNext = IDC_TXT_TELEINFO2;
  61. break ;
  62. case IDC_TXT_TELEINFO2:
  63. dwNext = IDC_TXT_TELEINFO3;
  64. break ;
  65. case IDC_TXT_TELEINFO3:
  66. dwNext = IDC_TXT_TELEINFO4;
  67. break ;
  68. case IDC_TXT_TELEINFO4:
  69. dwNext = IDC_TXT_TELEINFO5;
  70. break ;
  71. case IDC_TXT_TELEINFO5:
  72. dwNext = IDC_TXT_TELEINFO6;
  73. break ;
  74. case IDC_TXT_TELEINFO6:
  75. dwNext = IDC_TXT_TELEINFO7;
  76. break ;
  77. }
  78. if (dwNext != -1)
  79. {
  80. SetFocus(GetDlgItem(hwnd, dwNext));
  81. SendMessage(GetDlgItem(hwnd,dwNext),WM_KEYDOWN, VK_HOME,0);
  82. }
  83. break;
  84. }
  85. }
  86. LRW_DLG_INT CALLBACK
  87. TelLKPProc(
  88. IN HWND hwnd,
  89. IN UINT uMsg,
  90. IN WPARAM wParam,
  91. IN LPARAM lParam
  92. )
  93. {
  94. DWORD dwNextPage = 0;
  95. BOOL bStatus = TRUE;
  96. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  97. HWND hwndLSID;
  98. DWORD dwRetCode;
  99. TCHAR * cwRegistrationID;
  100. TCHAR awBuffer[ 128];
  101. TCHAR tcUserValue[ CHARS_IN_BATCH*NUMBER_OF_BATCHES + 1];
  102. switch (uMsg)
  103. {
  104. case WM_INITDIALOG:
  105. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  106. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  107. // Now set the Limit of the data entry fields
  108. // Now set the Limit of the data entry fields
  109. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO1, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  110. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO2, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  111. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO3, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  112. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO4, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  113. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO5, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  114. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO6, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  115. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO7, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  116. assert(NUMBER_OF_BATCHES == 7);
  117. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO1), _T(""));
  118. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO2), _T(""));
  119. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO3), _T(""));
  120. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO4), _T(""));
  121. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO5), _T(""));
  122. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO6), _T(""));
  123. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO7), _T(""));
  124. break;
  125. case WM_COMMAND:
  126. if (HIWORD(wParam) == EN_CHANGE)
  127. {
  128. MoveCaret(LOWORD(wParam), hwnd ) ;
  129. }
  130. if (HIWORD(wParam) == EN_UPDATE)
  131. {
  132. if (GetKeyState(VK_DELETE) == -128)
  133. SetDeleteKeyStatus(1) ;
  134. else
  135. SetDeleteKeyStatus(0) ;
  136. }
  137. break;
  138. case WM_DESTROY:
  139. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  140. break;
  141. case WM_NOTIFY:
  142. {
  143. LPNMHDR pnmh = (LPNMHDR)lParam;
  144. switch( pnmh->code )
  145. {
  146. case PSN_SETACTIVE:
  147. cwRegistrationID = GetGlobalContext()->GetRegistrationID();
  148. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK);
  149. // Get the License Server ID, provided by the License Server
  150. hwndLSID = GetDlgItem(hwnd, IDC_MSID);
  151. swprintf(awBuffer, L"%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s",
  152. cwRegistrationID, cwRegistrationID + 5, cwRegistrationID + 10,
  153. cwRegistrationID + 15, cwRegistrationID + 20, cwRegistrationID + 25,
  154. cwRegistrationID + 30);
  155. SetWindowText(hwndLSID, awBuffer);
  156. SetWindowText(GetDlgItem(hwnd, IDC_CSRINFO), GetCSRNumber());
  157. break;
  158. case PSN_WIZNEXT:
  159. // Let us get the Information Entered First & concatenate everything into
  160. // One String
  161. GetDlgItemText(hwnd,IDC_TXT_TELEINFO1, tcUserValue, CHARS_IN_BATCH+1);
  162. GetDlgItemText(hwnd,IDC_TXT_TELEINFO2, tcUserValue+1*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  163. GetDlgItemText(hwnd,IDC_TXT_TELEINFO3, tcUserValue+2*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  164. GetDlgItemText(hwnd,IDC_TXT_TELEINFO4, tcUserValue+3*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  165. GetDlgItemText(hwnd,IDC_TXT_TELEINFO5, tcUserValue+4*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  166. GetDlgItemText(hwnd,IDC_TXT_TELEINFO6, tcUserValue+5*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  167. GetDlgItemText(hwnd,IDC_TXT_TELEINFO7, tcUserValue+6*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  168. // OK, Now we have the Information provided by the user
  169. // Need to validate
  170. dwRetCode = SetLSLKP(tcUserValue);
  171. if (dwRetCode != ERROR_SUCCESS)
  172. {
  173. LRMessageBox(hwnd, dwRetCode,IDS_WIZARD_MESSAGE_TITLE);
  174. dwNextPage = IDD_DLG_TELLKP;
  175. }
  176. else
  177. {
  178. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  179. dwNextPage = IDD_PROGRESS;
  180. LRPush(IDD_DLG_TELLKP);
  181. }
  182. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  183. bStatus = -1;
  184. break;
  185. case PSN_WIZBACK:
  186. dwNextPage = LRPop();
  187. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  188. bStatus = -1;
  189. break;
  190. default:
  191. bStatus = FALSE;
  192. break;
  193. }
  194. }
  195. break;
  196. default:
  197. bStatus = FALSE;
  198. break;
  199. }
  200. return bStatus;
  201. }