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.

166 lines
4.8 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include "precomp.h"
  3. LRW_DLG_INT CALLBACK
  4. CHRegisterSelectDlgProc(
  5. IN HWND hwnd,
  6. IN UINT uMsg,
  7. IN WPARAM wParam,
  8. IN LPARAM lParam
  9. )
  10. {
  11. DWORD dwNextPage = 0;
  12. BOOL bStatus = TRUE;
  13. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  14. switch (uMsg)
  15. {
  16. case WM_INITDIALOG:
  17. {
  18. CString sProductType;
  19. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  20. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  21. SendDlgItemMessage(hwnd, IDC_TXT_ENROLLMENT_NUMBER, EM_SETLIMITTEXT, CH_SELECT_ENROLLMENT_NUMBER_LEN,0);
  22. SendDlgItemMessage(hwnd, IDC_TXT_QUANTITY, EM_SETLIMITTEXT, CH_QTY_LEN,0);
  23. PopulateProductComboBox(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE), PRODUCT_VERSION_UNDEFINED);
  24. //
  25. //Set the properties of the up-down control
  26. //
  27. SendDlgItemMessage(hwnd, IDC_SPIN1, UDM_SETBUDDY, (WPARAM)(HWND)GetDlgItem(hwnd,IDC_TXT_QUANTITY),(LPARAM)0);
  28. SendDlgItemMessage(hwnd, IDC_SPIN1, UDM_SETRANGE, 0,(LPARAM) MAKELONG (9999, 1));
  29. }
  30. break;
  31. case WM_DESTROY:
  32. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  33. break;
  34. case WM_NOTIFY:
  35. {
  36. LPNMHDR pnmh = (LPNMHDR)lParam;
  37. switch( pnmh->code )
  38. {
  39. case PSN_SETACTIVE:
  40. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  41. break;
  42. case PSN_WIZNEXT:
  43. {
  44. CString sProductCode;
  45. CString sProduct;
  46. CString sAgreementNumber;
  47. CString sEnrollmentNumber;
  48. CString sQuantity;
  49. LPTSTR lpVal = NULL;
  50. TCHAR lpBuffer[ 128];
  51. DWORD dwRetCode;
  52. int nCurSel = -1;
  53. //
  54. //Read all the fields
  55. //
  56. lpVal = sEnrollmentNumber.GetBuffer(CH_SELECT_ENROLLMENT_NUMBER_LEN+1);
  57. GetDlgItemText(hwnd,IDC_TXT_ENROLLMENT_NUMBER,lpVal,CH_SELECT_ENROLLMENT_NUMBER_LEN+1);
  58. sEnrollmentNumber.ReleaseBuffer(-1);
  59. lpVal = sQuantity.GetBuffer(CH_QTY_LEN+2);
  60. GetDlgItemText(hwnd,IDC_TXT_QUANTITY, lpBuffer,CH_QTY_LEN+2);
  61. TCHAR *lpStart = lpBuffer;
  62. do
  63. {
  64. if (*lpStart != (TCHAR) ',')
  65. {
  66. *lpVal++ = *lpStart;
  67. }
  68. } while ( *lpStart++ );
  69. sQuantity.ReleaseBuffer(-1);
  70. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE));
  71. lpVal = sProduct.GetBuffer(LR_PRODUCT_DESC_LEN+1);
  72. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE), nCurSel, lpVal);
  73. sProduct.ReleaseBuffer(-1);
  74. // Send Product Code instead of Desc -- 01/08/99
  75. lpVal = sProductCode.GetBuffer(16);
  76. GetProductCode(sProduct,lpVal);
  77. sProductCode.ReleaseBuffer(-1);
  78. sProductCode.TrimLeft(); sProductCode.TrimRight();
  79. sEnrollmentNumber.TrimLeft();sEnrollmentNumber.TrimRight();
  80. sQuantity.TrimLeft(); sQuantity.TrimRight();
  81. if(
  82. sProduct.IsEmpty() ||
  83. sEnrollmentNumber.IsEmpty() ||
  84. sQuantity.IsEmpty()
  85. )
  86. {
  87. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY,IDS_WIZARD_MESSAGE_TITLE);
  88. dwNextPage = IDD_CH_REGISTER_SELECT;
  89. goto NextDone;
  90. }
  91. if(
  92. !ValidateLRString(sProduct) ||
  93. !ValidateLRString(sAgreementNumber) ||
  94. !ValidateLRString(sEnrollmentNumber)
  95. )
  96. {
  97. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR,IDS_WIZARD_MESSAGE_TITLE);
  98. dwNextPage = IDD_CH_REGISTER_SELECT;
  99. goto NextDone;
  100. }
  101. if(_wtoi(sQuantity) < 1)
  102. {
  103. LRMessageBox(hwnd,IDS_ERR_INVALID_QTY,IDS_WIZARD_MESSAGE_TITLE);
  104. dwNextPage = IDD_CH_REGISTER_SELECT;
  105. goto NextDone;
  106. }
  107. GetGlobalContext()->GetLicDataObject()->sSelProductType = sProductCode; //sProduct;
  108. GetGlobalContext()->GetLicDataObject()->sSelProductDesc = sProduct;
  109. GetGlobalContext()->GetLicDataObject()->sSelMastAgrNumber = sAgreementNumber;
  110. GetGlobalContext()->GetLicDataObject()->sSelEnrollmentNumber = sEnrollmentNumber;
  111. GetGlobalContext()->GetLicDataObject()->sSelQty = sQuantity;
  112. // dwNextPage = IDD_PROCESSING;
  113. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  114. dwNextPage = IDD_PROGRESS;
  115. LRPush(IDD_CH_REGISTER_SELECT);
  116. NextDone:
  117. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  118. bStatus = -1;
  119. }
  120. break;
  121. case PSN_WIZBACK:
  122. dwNextPage = LRPop();
  123. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  124. bStatus = -1;
  125. break;
  126. default:
  127. bStatus = FALSE;
  128. break;
  129. }
  130. }
  131. break;
  132. default:
  133. bStatus = FALSE;
  134. break;
  135. }
  136. return bStatus;
  137. }