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.

174 lines
5.4 KiB

  1. //
  2. // thruputdlg.cpp: thruput dialog box
  3. //
  4. #include "stdafx.h"
  5. #define TRC_GROUP TRC_GROUP_UI
  6. #define TRC_FILE "thruputdlg"
  7. #include <atrcapi.h>
  8. #include "thruputdlg.h"
  9. #include "sh.h"
  10. #ifdef DC_DEBUG
  11. CThruPutDlg* CThruPutDlg::_pThruPutDlgInstance = NULL;
  12. CThruPutDlg::CThruPutDlg( HWND hwndOwner, HINSTANCE hInst, DCINT thruPut) :
  13. CDlgBase( hwndOwner, hInst, UI_IDD_NETWORKTHROUGHPUT)
  14. {
  15. DC_BEGIN_FN("CThruPutDlg");
  16. TRC_ASSERT((NULL == CThruPutDlg::_pThruPutDlgInstance),
  17. (TB,_T("Clobbering existing dlg instance pointer\n")));
  18. _thruPut = thruPut;
  19. CThruPutDlg::_pThruPutDlgInstance = this;
  20. DC_END_FN();
  21. }
  22. CThruPutDlg::~CThruPutDlg()
  23. {
  24. CThruPutDlg::_pThruPutDlgInstance = NULL;
  25. }
  26. DCINT CThruPutDlg::DoModal()
  27. {
  28. DCINT retVal = 0;
  29. DC_BEGIN_FN("DoModal");
  30. retVal = DialogBox(_hInstance, MAKEINTRESOURCE(_dlgResId),
  31. _hwndOwner, StaticDialogBoxProc);
  32. TRC_ASSERT((retVal != 0 && retVal != -1), (TB, _T("DialogBoxParam failed\n")));
  33. DC_END_FN();
  34. return retVal;
  35. }
  36. INT_PTR CALLBACK CThruPutDlg::StaticDialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  37. {
  38. //
  39. // Delegate to appropriate instance (only works for single instance dialogs)
  40. //
  41. DC_BEGIN_FN("StaticDialogBoxProc");
  42. DCINT retVal = 0;
  43. TRC_ASSERT(_pThruPutDlgInstance, (TB, _T("ThruPut dialog has NULL static instance ptr\n")));
  44. if(_pThruPutDlgInstance)
  45. {
  46. retVal = _pThruPutDlgInstance->DialogBoxProc( hwndDlg, uMsg, wParam, lParam);
  47. }
  48. DC_END_FN();
  49. return retVal;
  50. }
  51. /****************************************************************************/
  52. /* Name: DialogBoxProc */
  53. /* */
  54. /* Purpose: Handles ThruPut Box dialog (limits network thruput) */
  55. /* */
  56. /* Returns: TRUE if message dealt with */
  57. /* FALSE otherwise */
  58. /* */
  59. /* Params: See window documentation */
  60. /* */
  61. /****************************************************************************/
  62. INT_PTR CALLBACK CThruPutDlg::DialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  63. {
  64. INT_PTR rc = FALSE;
  65. DCTCHAR numberString[SH_NUMBER_STRING_MAX_LENGTH];
  66. DCUINT32 number;
  67. DC_BEGIN_FN("UINetworkThroughputDialogProc");
  68. TRC_DBG((TB, _T("Network throughput dialog")));
  69. switch (uMsg)
  70. {
  71. case WM_INITDIALOG:
  72. {
  73. /****************************************************************/
  74. /* Center the dialog. */
  75. /****************************************************************/
  76. _hwndDlg = hwndDlg;
  77. if(hwndDlg)
  78. {
  79. CenterWindow(NULL);
  80. SetDialogAppIcon(hwndDlg);
  81. /************************************************************/
  82. /* Set edit text with current throughput setting. */
  83. /************************************************************/
  84. TRC_ASSERT((HIWORD(_thruPut) == 0), (TB, _T("Losing information from _thruPut")));
  85. SetDlgItemText(hwndDlg,
  86. UI_IDC_NETWORKTHROUGHPUT_EDIT,
  87. DC_ITOT(LOWORD(_thruPut), numberString, 10));
  88. }
  89. rc = TRUE;
  90. }
  91. break;
  92. case WM_COMMAND:
  93. {
  94. switch (wParam)
  95. {
  96. case UI_IDB_NETWORKTHROUGHPUT_OK:
  97. {
  98. rc = TRUE;
  99. if(hwndDlg)
  100. {
  101. GetWindowText(GetDlgItem(hwndDlg, UI_IDC_NETWORKTHROUGHPUT_EDIT),
  102. numberString,
  103. SH_NUMBER_STRING_MAX_LENGTH);
  104. number = (DCUINT32)DC_TTOI(numberString);
  105. if (number <= 50000)
  106. {
  107. _thruPut = number;
  108. EndDialog(hwndDlg, IDOK);
  109. }
  110. }
  111. }
  112. break;
  113. default:
  114. {
  115. if(hwndDlg)
  116. {
  117. rc = CDlgBase::DialogBoxProc(hwndDlg,
  118. uMsg,
  119. wParam,
  120. lParam);
  121. }
  122. }
  123. break;
  124. }
  125. }
  126. break;
  127. default:
  128. {
  129. if(hwndDlg)
  130. {
  131. rc = CDlgBase::DialogBoxProc(hwndDlg,
  132. uMsg,
  133. wParam,
  134. lParam);
  135. }
  136. }
  137. break;
  138. }
  139. DC_END_FN();
  140. return(rc);
  141. }
  142. #endif //DC_DEBUG