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.

637 lines
18 KiB

  1. // browsctr.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "DPH_TEST.h"
  5. #include "browsctr.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CBrowsCountersDlg dialog
  12. CBrowsCountersDlg::CBrowsCountersDlg(CWnd* pParent /*=NULL*/,
  13. UINT nTemplate /* = IDD_BROWSE_COUNTERS_DLG_EXT */)
  14. : CDialog(nTemplate, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CBrowsCountersDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. // initialize the private/public variables here
  20. wpLastMachineSel = 0;
  21. cpeLastSelection.szMachineName = &cpeMachineName[0];
  22. memset (cpeMachineName, 0, sizeof(cpeMachineName));
  23. cpeLastSelection.szObjectName = &cpeObjectName[0];
  24. memset (cpeObjectName, 0, sizeof(cpeObjectName));
  25. cpeLastSelection.szInstanceName = &cpeInstanceName[0];
  26. memset (cpeInstanceName, 0, sizeof(cpeInstanceName));
  27. cpeLastSelection.szParentInstance = &cpeParentInstance[0];
  28. memset (cpeParentInstance, 0, sizeof(cpeParentInstance));
  29. cpeLastSelection.dwInstanceIndex = (DWORD)-1;
  30. cpeLastSelection.szCounterName = &cpeCounterName[0];
  31. memset (cpeCounterName, 0, sizeof(cpeCounterName));
  32. memset (cpeLastPath, 0, sizeof(cpeLastPath));
  33. bShowIndex = FALSE;
  34. bSelectMultipleCounters = FALSE;
  35. bAddMultipleCounters = TRUE;
  36. bIncludeMachineInPath = FALSE;
  37. szUsersPathBuffer = NULL;
  38. dwUsersPathBufferLength = 0;
  39. pCallBack = NULL;
  40. }
  41. void CBrowsCountersDlg::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CBrowsCountersDlg)
  45. // NOTE: the ClassWizard will add DDX and DDV calls here
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CBrowsCountersDlg, CDialog)
  49. //{{AFX_MSG_MAP(CBrowsCountersDlg)
  50. ON_CBN_SETFOCUS(IDC_MACHINE_COMBO, OnSetfocusMachineCombo)
  51. ON_CBN_KILLFOCUS(IDC_MACHINE_COMBO, OnKillfocusMachineCombo)
  52. ON_CBN_SELCHANGE(IDC_OBJECT_COMBO, OnSelchangeObjectCombo)
  53. ON_LBN_SELCHANGE(IDC_COUNTER_LIST, OnSelchangeCounterList)
  54. ON_LBN_SELCHANGE(IDC_INSTANCE_LIST, OnSelchangeInstanceList)
  55. ON_BN_CLICKED(IDC_USE_LOCAL_MACHINE, OnUseLocalMachine)
  56. ON_BN_CLICKED(IDC_SELECT_MACHINE, OnSelectMachine)
  57. ON_BN_CLICKED(IDC_ALL_INSTANCES, OnAllInstances)
  58. ON_BN_CLICKED(IDC_USE_INSTANCE_LIST, OnUseInstanceList)
  59. ON_BN_CLICKED(IDC_HELP, OnHelp)
  60. ON_BN_CLICKED(IDC_NETWORK, OnNetwork)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Utility Functions
  65. #define MACHINE_LIST_SIZE 1024
  66. #define OBJECT_LIST_SIZE 4096
  67. #define COUNTER_LIST_SIZE 8192
  68. #define INSTANCE_LIST_SIZE 8192
  69. void CBrowsCountersDlg::LoadKnownMachines ()
  70. {
  71. TCHAR mszMachineList[MACHINE_LIST_SIZE];
  72. LPTSTR szThisMachine;
  73. DWORD dwLength;
  74. PDH_STATUS status;
  75. HCURSOR hOldCursor;
  76. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  77. dwLength = MACHINE_LIST_SIZE;
  78. status = PdhEnumConnectedMachines (
  79. &mszMachineList[0],
  80. &dwLength);
  81. SendDlgItemMessage(IDC_MACHINE_COMBO, CB_RESETCONTENT);
  82. if (status == ERROR_SUCCESS) {
  83. // update the combo box
  84. for (szThisMachine = &mszMachineList[0];
  85. *szThisMachine != 0;
  86. szThisMachine += lstrlen(szThisMachine)+1) {
  87. SendDlgItemMessage (IDC_MACHINE_COMBO, CB_ADDSTRING,
  88. 0, (LPARAM)szThisMachine);
  89. }
  90. SendDlgItemMessage (IDC_MACHINE_COMBO, CB_SETCURSEL);
  91. }
  92. ::SetCursor (hOldCursor);
  93. }
  94. void CBrowsCountersDlg::LoadMachineObjects (BOOL bRefresh)
  95. {
  96. TCHAR szMachineName[MAX_PATH];
  97. TCHAR szDefaultObject[MAX_PATH];
  98. TCHAR mszObjectList[OBJECT_LIST_SIZE];
  99. DWORD dwLength;
  100. LPTSTR szThisObject;
  101. HCURSOR hOldCursor;
  102. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  103. // get current machine name
  104. (GetDlgItem(IDC_MACHINE_COMBO))->GetWindowText(szMachineName, MAX_PATH);
  105. // get object list
  106. dwLength = OBJECT_LIST_SIZE;
  107. PdhEnumObjects (szMachineName, mszObjectList, &dwLength, bRefresh);
  108. // load object list
  109. SendDlgItemMessage (IDC_OBJECT_COMBO, CB_RESETCONTENT);
  110. for (szThisObject = &mszObjectList[0];
  111. *szThisObject != 0;
  112. szThisObject += lstrlen(szThisObject) + 1) {
  113. SendDlgItemMessage (IDC_OBJECT_COMBO, CB_ADDSTRING,
  114. 0, (LPARAM)szThisObject);
  115. }
  116. // get default Object
  117. dwLength = MAX_PATH;
  118. PdhGetDefaultPerfObject (
  119. szMachineName,
  120. szDefaultObject,
  121. &dwLength);
  122. if (SendDlgItemMessage (IDC_OBJECT_COMBO, CB_SELECTSTRING,
  123. (WPARAM)-1, (LPARAM)szDefaultObject) == CB_ERR) {
  124. // default object not found in list so select the first one
  125. SendDlgItemMessage (IDC_OBJECT_COMBO, CB_SETCURSEL);
  126. }
  127. ::SetCursor (hOldCursor);
  128. }
  129. void CBrowsCountersDlg::LoadCountersAndInstances ()
  130. {
  131. TCHAR szMachineName[MAX_PATH];
  132. TCHAR szObjectName[MAX_PATH];
  133. TCHAR szDefaultCounter[MAX_PATH];
  134. TCHAR mszCounterList[COUNTER_LIST_SIZE];
  135. TCHAR mszInstanceList[INSTANCE_LIST_SIZE];
  136. TCHAR szInstanceString[MAX_PATH];
  137. LPTSTR szIndexStringPos;
  138. DWORD dwCounterLen;
  139. DWORD dwDefaultIndex;
  140. DWORD dwCounterListLength;
  141. DWORD dwInstanceListLength;
  142. DWORD dwInstanceMatch;
  143. DWORD dwInstanceIndex;
  144. LPTSTR szThisItem;
  145. CWnd *pcCounterListBox;
  146. CWnd *pcInstanceListBox;
  147. HCURSOR hOldCursor;
  148. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  149. // get current machine & object name
  150. (GetDlgItem(IDC_MACHINE_COMBO))->GetWindowText(szMachineName, MAX_PATH);
  151. (GetDlgItem(IDC_OBJECT_COMBO))->GetWindowText(szObjectName, MAX_PATH);
  152. // get object list
  153. dwCounterListLength = sizeof(mszCounterList) / sizeof(TCHAR);
  154. dwInstanceListLength = sizeof(mszInstanceList) / sizeof(TCHAR);
  155. PdhEnumObjectItems (
  156. szMachineName,
  157. szObjectName,
  158. mszCounterList,
  159. &dwCounterListLength,
  160. mszInstanceList,
  161. &dwInstanceListLength,
  162. 0);
  163. //reset contents of both list boxes
  164. pcCounterListBox = GetDlgItem (IDC_COUNTER_LIST);
  165. pcInstanceListBox = GetDlgItem (IDC_INSTANCE_LIST);
  166. pcCounterListBox->SendMessage (LB_RESETCONTENT);
  167. pcInstanceListBox->SendMessage (LB_RESETCONTENT);
  168. // now fill 'em up
  169. // start with the counters
  170. for (szThisItem = mszCounterList;
  171. *szThisItem != 0;
  172. szThisItem += lstrlen(szThisItem) + 1) {
  173. pcCounterListBox->SendMessage (LB_ADDSTRING, 0, (LPARAM)szThisItem);
  174. }
  175. dwCounterLen = MAX_PATH;
  176. PdhGetDefaultPerfCounter (
  177. szMachineName,
  178. szObjectName,
  179. szDefaultCounter,
  180. &dwCounterLen);
  181. dwDefaultIndex = pcCounterListBox->SendMessage (LB_FINDSTRINGEXACT,
  182. (WPARAM)-1, (LPARAM)szDefaultCounter);
  183. if (dwDefaultIndex == LB_ERR) {
  184. pcCounterListBox->SendMessage (LB_SETSEL, TRUE, 0);
  185. } else {
  186. pcCounterListBox->SendMessage (LB_SETSEL, TRUE, dwDefaultIndex);
  187. pcCounterListBox->SendMessage (LB_SETCARETINDEX, (WPARAM)dwDefaultIndex,
  188. MAKELPARAM(FALSE, 0));
  189. }
  190. // now the instance list
  191. if (dwInstanceListLength > 0) {
  192. pcInstanceListBox->EnableWindow(TRUE);
  193. GetDlgItem(IDC_ALL_INSTANCES)->EnableWindow(TRUE);
  194. GetDlgItem(IDC_USE_INSTANCE_LIST)->EnableWindow(TRUE);
  195. for (szThisItem = mszInstanceList;
  196. *szThisItem != 0;
  197. szThisItem += lstrlen(szThisItem) + 1) {
  198. if (bShowIndex) {
  199. dwInstanceIndex = 0;
  200. dwInstanceMatch = (DWORD)-1;
  201. // find the index of this instance
  202. lstrcpy (szInstanceString, szThisItem);
  203. lstrcat (szInstanceString, TEXT("#"));
  204. szIndexStringPos = &szInstanceString[lstrlen(szInstanceString)];
  205. do {
  206. LongToString ((long)dwInstanceIndex++, szIndexStringPos, 10);
  207. dwInstanceMatch = (DWORD)SendDlgItemMessage (IDC_INSTANCE_LIST,
  208. LB_FINDSTRINGEXACT,
  209. (WPARAM)dwInstanceMatch, (LPARAM)szInstanceString);
  210. } while (dwInstanceMatch != LB_ERR);
  211. pcInstanceListBox->SendMessage (LB_ADDSTRING, 0, (LPARAM)szInstanceString);
  212. } else {
  213. pcInstanceListBox->SendMessage (LB_ADDSTRING, 0, (LPARAM)szThisItem);
  214. }
  215. }
  216. if (bWildCardInstances) {
  217. // disable instance list
  218. pcInstanceListBox->EnableWindow(FALSE);
  219. } else {
  220. if (pcInstanceListBox->SendMessage (LB_GETCOUNT) != LB_ERR) {
  221. pcInstanceListBox->SendMessage (LB_SETSEL, TRUE, 0);
  222. }
  223. }
  224. } else {
  225. pcInstanceListBox->SendMessage (LB_ADDSTRING, 0, (LPARAM)TEXT("<No Instances>"));
  226. pcInstanceListBox->EnableWindow(FALSE);
  227. GetDlgItem(IDC_ALL_INSTANCES)->EnableWindow(FALSE);
  228. GetDlgItem(IDC_USE_INSTANCE_LIST)->EnableWindow(FALSE);
  229. }
  230. ::SetCursor (hOldCursor);
  231. }
  232. void CBrowsCountersDlg::CompileSelectedCounters()
  233. {
  234. DWORD dwBufferRemaining;
  235. DWORD dwCountCounters;
  236. DWORD dwThisCounter;
  237. DWORD dwCountInstances;
  238. DWORD dwThisInstance;
  239. DWORD dwSize1, dwSize2;
  240. PDH_COUNTER_PATH_ELEMENTS lszPath;
  241. TCHAR lszMachineName[MAX_PATH];
  242. TCHAR lszObjectName[MAX_PATH];
  243. TCHAR lszInstanceName[MAX_PATH];
  244. TCHAR lszParentInstance[MAX_PATH];
  245. TCHAR lszCounterName[MAX_PATH];
  246. TCHAR szWorkBuffer[MAX_PATH];
  247. LPTSTR szCounterStart;
  248. CWnd *cwCounterList, *cwInstanceList;
  249. // clear user's string
  250. if (szUsersPathBuffer != NULL) {
  251. *szUsersPathBuffer = 0;
  252. dwBufferRemaining = dwUsersPathBufferLength;
  253. szCounterStart = szUsersPathBuffer;
  254. } else {
  255. return; // no point in continuing if user doesn't have a buffer
  256. }
  257. // build base string using selected machine and object
  258. if (bIncludeMachineInPath) {
  259. lszPath.szMachineName = &lszMachineName[0];
  260. memset (lszMachineName, 0, sizeof(lszMachineName));
  261. GetDlgItemText (IDC_MACHINE_COMBO, lszMachineName, MAX_PATH);
  262. } else {
  263. lszPath.szMachineName = NULL;
  264. }
  265. lszPath.szObjectName = &lszObjectName[0];
  266. memset (lszObjectName, 0, sizeof(lszObjectName));
  267. GetDlgItemText (IDC_OBJECT_COMBO, lszObjectName, MAX_PATH);
  268. cwCounterList = GetDlgItem (IDC_COUNTER_LIST);
  269. cwInstanceList = GetDlgItem (IDC_INSTANCE_LIST);
  270. if (bSelectMultipleCounters) {
  271. if (bWildCardInstances) {
  272. lszPath.szInstanceName = &lszInstanceName[0];
  273. memset (lszInstanceName, 0, sizeof(lszInstanceName));
  274. lstrcpy (lszInstanceName, TEXT("*"));
  275. lszPath.szParentInstance = NULL;
  276. lszPath.dwInstanceIndex = (DWORD)-1;
  277. dwSize1 = sizeof (szWorkBuffer) / sizeof (TCHAR);
  278. PdhMakeCounterPath (&lszPath,
  279. szWorkBuffer,
  280. &dwSize1,
  281. 0);
  282. if ((dwSize1 + 1) < dwBufferRemaining) {
  283. // then this will fit so add it to the string
  284. lstrcpy (szCounterStart, szWorkBuffer);
  285. szCounterStart += lstrlen(szWorkBuffer);
  286. *szCounterStart++ = 0;
  287. }
  288. } else {
  289. // get selected instances from list
  290. dwCountCounters = cwCounterList->SendMessage (LB_GETCOUNT);
  291. for (dwThisCounter = 0; dwThisCounter < dwCountCounters; dwThisCounter++) {
  292. if (cwCounterList->SendMessage (LB_GETSEL, (WPARAM)dwThisCounter)) {
  293. lszPath.szCounterName = &lszCounterName[0];
  294. memset (lszCounterName, 0, sizeof(lszCounterName));
  295. cwCounterList->SendMessage (LB_GETTEXT, (WPARAM)dwThisCounter, (LPARAM)lszCounterName);
  296. if (cwInstanceList->IsWindowEnabled()) {
  297. dwCountInstances = cwInstanceList->SendMessage (LB_GETCOUNT);
  298. for (dwThisInstance = 0; dwThisInstance < dwCountInstances; dwThisInstance++) {
  299. if (cwInstanceList->SendMessage (LB_GETSEL, (WPARAM)dwThisInstance)) {
  300. lszPath.szInstanceName = &lszInstanceName[0];
  301. memset (lszInstanceName, 0, sizeof(lszInstanceName));
  302. cwInstanceList->SendMessage (LB_GETTEXT,
  303. (WPARAM)dwThisInstance, (LPARAM)lszInstanceName);
  304. lszPath.szParentInstance = &lszParentInstance[0];
  305. memset (lszParentInstance, 0, sizeof(lszParentInstance));
  306. dwSize1 = dwSize2 = MAX_PATH;
  307. PdhParseInstanceName (lszInstanceName,
  308. lszInstanceName,
  309. &dwSize1,
  310. lszParentInstance,
  311. &dwSize2,
  312. &lszPath.dwInstanceIndex);
  313. // parse instance name adds in the default index of one is
  314. // not present. so if it's not wanted, this will remove it
  315. if (!bShowIndex) lszPath.dwInstanceIndex = (DWORD)-1;
  316. if (dwSize1 > 0) {
  317. lszPath.szInstanceName = &lszInstanceName[0];
  318. } else {
  319. lszPath.szInstanceName = NULL;
  320. }
  321. if (dwSize2 > 0) {
  322. lszPath.szParentInstance = &lszParentInstance[0];
  323. } else {
  324. lszPath.szParentInstance = NULL;
  325. }
  326. dwSize1 = sizeof (szWorkBuffer) / sizeof (TCHAR);
  327. PdhMakeCounterPath (&lszPath,
  328. szWorkBuffer,
  329. &dwSize1,
  330. 0);
  331. if ((dwSize1 + 1) < dwBufferRemaining) {
  332. // then this will fit so add it to the string
  333. lstrcpy (szCounterStart, szWorkBuffer);
  334. szCounterStart += lstrlen(szWorkBuffer);
  335. *szCounterStart++ = 0;
  336. }
  337. } // end if instance is selected
  338. } // end for each instance in list
  339. } else {
  340. // this counter has no instances so process now
  341. lszPath.szInstanceName = NULL;
  342. lszPath.szParentInstance = NULL;
  343. lszPath.dwInstanceIndex = (DWORD)-1;
  344. dwSize1 = sizeof (szWorkBuffer) / sizeof (TCHAR);
  345. PdhMakeCounterPath (&lszPath,
  346. szWorkBuffer,
  347. &dwSize1,
  348. 0);
  349. if ((dwSize1 + 1) < dwBufferRemaining) {
  350. // then this will fit so add it to the string
  351. lstrcpy (szCounterStart, szWorkBuffer);
  352. szCounterStart += lstrlen(szWorkBuffer);
  353. *szCounterStart++ = 0;
  354. }
  355. } // end if counter has instances
  356. } // else counter is not selected
  357. } // end for each counter in list
  358. } // end if not wild card instances
  359. *szCounterStart++ = 0; // terminate MSZ
  360. } else {
  361. // only single selections are allowed
  362. // FIXFIX: add this code.
  363. }
  364. }
  365. ////////////////////////////////////////////////////////////////////////////
  366. // CBrowsCountersDlg message handlers
  367. BOOL CBrowsCountersDlg::OnInitDialog()
  368. {
  369. HCURSOR hOldCursor;
  370. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  371. CDialog::OnInitDialog();
  372. // limit text to machine name
  373. (GetDlgItem(IDC_MACHINE_COMBO))->SendMessage(EM_LIMITTEXT, MAX_PATH);
  374. // set check boxes to the caller defined setting
  375. CheckRadioButton (IDC_USE_LOCAL_MACHINE, IDC_SELECT_MACHINE,
  376. (bIncludeMachineInPath ? IDC_SELECT_MACHINE : IDC_USE_LOCAL_MACHINE));
  377. GetDlgItem(IDC_MACHINE_COMBO)->EnableWindow (
  378. (bIncludeMachineInPath ? TRUE : FALSE));
  379. CheckRadioButton (IDC_ALL_INSTANCES, IDC_USE_INSTANCE_LIST,
  380. IDC_USE_INSTANCE_LIST);
  381. // set button text strings to reflect mode of dialog
  382. if (bAddMultipleCounters) {
  383. (GetDlgItem(IDOK))->SetWindowText(TEXT("Add"));
  384. (GetDlgItem(IDCANCEL))->SetWindowText(TEXT("Close"));
  385. }
  386. // connect to this machine
  387. PdhConnectMachine(NULL); // Null is local machine
  388. LoadKnownMachines(); // load machine list
  389. LoadMachineObjects(TRUE); // load object list
  390. LoadCountersAndInstances();
  391. wpLastMachineSel = 0;
  392. ::SetCursor (hOldCursor);
  393. return TRUE; // return TRUE unless you set the focus to a control
  394. // EXCEPTION: OCX Property Pages should return FALSE
  395. }
  396. void CBrowsCountersDlg::OnOK()
  397. {
  398. HCURSOR hOldCursor;
  399. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  400. CompileSelectedCounters();
  401. if (pCallBack != NULL) {
  402. (*pCallBack)(dwArg);
  403. }
  404. if (!bAddMultipleCounters) {
  405. CDialog::OnOK();
  406. }
  407. ::SetCursor (hOldCursor);
  408. }
  409. void CBrowsCountersDlg::OnCancel()
  410. {
  411. CDialog::OnCancel();
  412. }
  413. void CBrowsCountersDlg::OnSetfocusMachineCombo()
  414. {
  415. wpLastMachineSel = SendDlgItemMessage (IDC_MACHINE_COMBO, CB_GETCURSEL);
  416. }
  417. void CBrowsCountersDlg::OnKillfocusMachineCombo()
  418. {
  419. TCHAR szNewMachineName[MAX_PATH];
  420. CWnd *pcMachineCombo;
  421. long lMatchIndex;
  422. PDH_STATUS status;
  423. int mbStatus;
  424. HCURSOR hOldCursor;
  425. hOldCursor = ::SetCursor (::LoadCursor (NULL, IDC_WAIT));
  426. pcMachineCombo = GetDlgItem(IDC_MACHINE_COMBO);
  427. // Get current combo box text
  428. pcMachineCombo->GetWindowText (szNewMachineName, MAX_PATH);
  429. // see if it's in the combo box already
  430. lMatchIndex = (long)pcMachineCombo->SendMessage (
  431. CB_FINDSTRING,(WPARAM)-1, (LPARAM)szNewMachineName);
  432. // if name is in list, then select it
  433. if (lMatchIndex != CB_ERR) {
  434. // this name is already in the list so see if it's the same as the last selected machine
  435. if (lstrcmpi (szNewMachineName, cpeMachineName) != 0) {
  436. // this is a different machine so update the display
  437. pcMachineCombo->SendMessage (CB_SETCURSEL, (WPARAM)lMatchIndex);
  438. LoadMachineObjects (TRUE);
  439. LoadCountersAndInstances ();
  440. }
  441. } else {
  442. // not in list so try to add it
  443. status = PdhConnectMachine (szNewMachineName);
  444. if (status == ERROR_SUCCESS) {
  445. // if successful, add string to combo box
  446. lMatchIndex = pcMachineCombo->SendMessage (CB_ADDSTRING, 0, (LPARAM)szNewMachineName);
  447. pcMachineCombo->SendMessage (CB_SETCURSEL, (WPARAM)lMatchIndex);
  448. // update other fields
  449. LoadMachineObjects (); // no need to update since it was just connected
  450. LoadCountersAndInstances ();
  451. } else {
  452. mbStatus = MessageBox (TEXT("Unable to connect to machine"), NULL,
  453. MB_ICONEXCLAMATION | MB_TASKMODAL | MB_OKCANCEL);
  454. if (mbStatus == IDCANCEL) {
  455. GetDlgItem(IDC_MACHINE_COMBO)->SetFocus();
  456. } else {
  457. pcMachineCombo->SendMessage (CB_SETCURSEL, wpLastMachineSel);
  458. }
  459. }
  460. }
  461. ::SetCursor (hOldCursor);
  462. }
  463. void CBrowsCountersDlg::OnSelchangeObjectCombo()
  464. {
  465. LoadCountersAndInstances();
  466. }
  467. void CBrowsCountersDlg::OnSelchangeCounterList()
  468. {
  469. }
  470. void CBrowsCountersDlg::OnSelchangeInstanceList()
  471. {
  472. }
  473. void CBrowsCountersDlg::OnUseLocalMachine()
  474. {
  475. BOOL bMode;
  476. bMode = !(BOOL)IsDlgButtonChecked(IDC_USE_LOCAL_MACHINE);
  477. GetDlgItem(IDC_MACHINE_COMBO)->EnableWindow(bMode);
  478. bIncludeMachineInPath = bMode;
  479. }
  480. void CBrowsCountersDlg::OnSelectMachine()
  481. {
  482. BOOL bMode ;
  483. bMode = (BOOL)IsDlgButtonChecked(IDC_SELECT_MACHINE);
  484. GetDlgItem(IDC_MACHINE_COMBO)->EnableWindow(bMode);
  485. bIncludeMachineInPath = bMode;
  486. }
  487. void CBrowsCountersDlg::OnAllInstances()
  488. {
  489. BOOL bMode;
  490. CWnd *pInstanceList;
  491. bMode = (BOOL)IsDlgButtonChecked(IDC_ALL_INSTANCES);
  492. pInstanceList = GetDlgItem(IDC_INSTANCE_LIST);
  493. // if "Sselect ALL" then clear list box selections and disable
  494. if (bMode) {
  495. pInstanceList->SendMessage(LB_SETSEL, FALSE, (LPARAM)-1);
  496. }
  497. pInstanceList->EnableWindow(!bMode);
  498. bWildCardInstances = bMode;
  499. }
  500. void CBrowsCountersDlg::OnUseInstanceList()
  501. {
  502. BOOL bMode;
  503. CWnd *pInstanceList;
  504. bMode = (BOOL)IsDlgButtonChecked(IDC_USE_INSTANCE_LIST);
  505. pInstanceList = GetDlgItem(IDC_INSTANCE_LIST);
  506. // enable list box and select 1st Instance
  507. pInstanceList->EnableWindow(bMode);
  508. if (bMode) {
  509. if (pInstanceList->SendMessage(LB_GETCOUNT) > 0) {
  510. pInstanceList->SendMessage (LB_SETSEL, TRUE, 0);
  511. }
  512. }
  513. bWildCardInstances = !bMode;
  514. }
  515. void CBrowsCountersDlg::OnHelp()
  516. {
  517. }
  518. void CBrowsCountersDlg::OnNetwork()
  519. {
  520. }
  521.