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.

169 lines
5.1 KiB

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