Source code of Windows XP (NT5)
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.

156 lines
4.1 KiB

  1. /*****************************************************************************
  2. *
  3. * ChoseCom.c - This module handles the Dialog user interactions for the
  4. * choose computers within a log file
  5. *
  6. * Microsoft Confidential
  7. * Copyright (c) 1992-1993 Microsoft Corporation
  8. *
  9. ****************************************************************************/
  10. //==========================================================================//
  11. // Includes //
  12. //==========================================================================//
  13. #include "perfmon.h" // basic defns, windows.h
  14. #include "dlgs.h" // common dialog control IDs
  15. #include "playback.h" // for PlayingBackLog
  16. #include "pmhelpid.h" // Help IDs
  17. #include "utils.h" // for CallWinHelp
  18. static LPTSTR lpChooseComputerText ;
  19. static DWORD TextLength ;
  20. //==========================================================================//
  21. // Message Handlers //
  22. //==========================================================================//
  23. void
  24. static
  25. OnInitDialog (
  26. HDLG hDlg
  27. )
  28. {
  29. // build the listbox of computers wintin the log file
  30. BuildLogComputerList (hDlg, IDD_CHOOSECOMPUTERLISTBOX) ;
  31. // set the scroll limit on the edit box
  32. EditSetLimit (GetDlgItem(hDlg, IDD_CHOOSECOMPUTERNAME), TextLength-1) ;
  33. dwCurrentDlgID = HC_PM_idDlgLogComputerList ;
  34. WindowCenter (hDlg) ;
  35. }
  36. void
  37. static
  38. OnOK (
  39. HDLG hDlg
  40. )
  41. {
  42. GetDlgItemText (hDlg,
  43. IDD_CHOOSECOMPUTERNAME,
  44. lpChooseComputerText,
  45. TextLength-1) ;
  46. }
  47. void
  48. OnComputerSelectionChanged (
  49. HWND hDlg
  50. )
  51. {
  52. TCHAR localComputerName [MAX_PATH + 3] ;
  53. INT_PTR SelectedIndex ;
  54. HWND hWndLB = GetDlgItem (hDlg, IDD_CHOOSECOMPUTERLISTBOX) ;
  55. // get the listbox selection and put it in the editbox
  56. SelectedIndex = LBSelection (hWndLB) ;
  57. if (SelectedIndex != LB_ERR) {
  58. localComputerName[0] = TEXT('\0') ;
  59. if (LBString (hWndLB, SelectedIndex, localComputerName) != LB_ERR &&
  60. localComputerName[0]) {
  61. SetDlgItemText (hDlg, IDD_CHOOSECOMPUTERNAME, localComputerName) ;
  62. }
  63. }
  64. }
  65. INT_PTR
  66. ChooseLogComputerDlgProc(
  67. HWND hDlg,
  68. UINT msg,
  69. WPARAM wParam,
  70. LPARAM lParam
  71. )
  72. {
  73. switch (msg) {
  74. case WM_INITDIALOG:
  75. OnInitDialog (hDlg) ;
  76. break ;
  77. case WM_COMMAND:
  78. switch (LOWORD(wParam)) {
  79. case IDOK:
  80. OnOK (hDlg) ;
  81. dwCurrentDlgID = 0 ;
  82. EndDialog (hDlg, TRUE) ;
  83. return (TRUE) ;
  84. break ;
  85. case IDCANCEL:
  86. dwCurrentDlgID = 0 ;
  87. EndDialog (hDlg, FALSE) ;
  88. return (TRUE) ;
  89. case ID_HELP:
  90. CallWinHelp (dwCurrentDlgID, hDlg) ;
  91. break ;
  92. case IDD_CHOOSECOMPUTERLISTBOX:
  93. if (HIWORD (wParam) == LBN_SELCHANGE)
  94. OnComputerSelectionChanged (hDlg) ;
  95. break ;
  96. default:
  97. break;
  98. }
  99. break ;
  100. default:
  101. break ;
  102. }
  103. return (FALSE) ;
  104. }
  105. BOOL
  106. GetLogFileComputer (
  107. HWND hWndParent,
  108. LPTSTR lpComputerName,
  109. DWORD BufferSize
  110. )
  111. {
  112. BOOL bSuccess ;
  113. DWORD LocalDlgID = dwCurrentDlgID ;
  114. // initialize some globals
  115. *lpComputerName = TEXT('\0') ;
  116. lpChooseComputerText = lpComputerName ;
  117. TextLength = BufferSize ;
  118. bSuccess = DialogBox (hInstance, idDlgChooseComputer, hWndParent, ChooseLogComputerDlgProc) ? TRUE : FALSE;
  119. dwCurrentDlgID = LocalDlgID ;
  120. if (*lpComputerName == '\0') {
  121. bSuccess = FALSE ;
  122. }
  123. return (bSuccess) ;
  124. }