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.

658 lines
15 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: T A G S P A G E . C P P
  7. //
  8. // Contents: TraceTags propsheet page handlers
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 24 Jan 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.h>
  16. #pragma hdrstop
  17. #ifdef ENABLETRACE
  18. #include <crtdbg.h>
  19. #include "ncdebug.h"
  20. #include <ncui.h>
  21. #include "traceui.h"
  22. //---[ Globals ]--------------------------------------------------------------
  23. #if 0
  24. typedef struct _LV_COLUMN {
  25. UINT mask;
  26. int fmt;
  27. int cx;
  28. PWSTR pszText;
  29. int cchTextMax;
  30. int iSubItem;
  31. } LV_COLUMN;
  32. #endif
  33. // | :--------- CHAR [] szShortName
  34. // | | :------- CHAR [] szDescription
  35. // | | | BOOL fOutputDebugString -----------------------------:
  36. // | | | BOOL fOutputToFile ----------------------------------|---:
  37. // | | | BOOL fVerboseOnly------------------------------------|---|---:
  38. #define LVCF_NORMAL (LVCF_FMT | LVCF_TEXT | LVCF_WIDTH)
  39. static LV_COLUMN g_lvcTags[] =
  40. {
  41. {LVCF_NORMAL, LVCFMT_LEFT, 30, L"Name", 0, 0},
  42. {LVCF_NORMAL, LVCFMT_LEFT, 60, L"Description", 0, 0},
  43. {LVCF_NORMAL, LVCFMT_LEFT, 30, L"Debug Logging", 0, 0},
  44. {LVCF_NORMAL, LVCFMT_LEFT, 30, L"File Logging", 0, 0}
  45. };
  46. const DWORD g_dwTagColumnCount = celems(g_lvcTags);
  47. static const UINT SELS_UNCHECKED = 0x1;
  48. static const UINT SELS_CHECKED = 0x2;
  49. CDbgFlagPage::CDbgFlagPage()
  50. {
  51. }
  52. //+---------------------------------------------------------------------------
  53. //
  54. // Member: CDbgFlagPage::~CDbgFlagPage
  55. //
  56. // Purpose: Destroys the CDbgFlagPage object
  57. //
  58. // Arguments:
  59. // (none)
  60. //
  61. // Returns: Nothing
  62. //
  63. // Author: danielwe 25 Feb 1998
  64. //
  65. // Notes:
  66. //
  67. CDbgFlagPage::~CDbgFlagPage()
  68. {
  69. }
  70. //+---------------------------------------------------------------------------
  71. //
  72. // Member: CDbgFlagPage::OnInitDialog
  73. //
  74. // Purpose: Handles the WM_INITDIALOG message
  75. //
  76. // Arguments:
  77. // uMsg []
  78. // wParam []
  79. // lParam []
  80. // bHandled []
  81. //
  82. // Returns: TRUE
  83. //
  84. // Author: danielwe 29 Oct 1997
  85. //
  86. // Notes:
  87. //
  88. LRESULT CDbgFlagPage::OnInitDialog(UINT uMsg, WPARAM wParam,
  89. LPARAM lParam, BOOL& bHandled)
  90. {
  91. HRESULT hr = S_OK;
  92. m_hwndLV = GetDlgItem(IDC_TRACETAGS);
  93. hr = HrInitTraceListView(m_hwndLV, &m_hilCheckIcons);
  94. for(DWORD dwLoop = 0; dwLoop < g_dwTagColumnCount; dwLoop++)
  95. {
  96. ListView_InsertColumn(m_hwndLV,dwLoop+1,&(g_lvcTags[dwLoop]));
  97. }
  98. LV_ITEM lvi = {0};
  99. lvi.mask = LVIF_TEXT | LVIF_IMAGE |
  100. LVIF_STATE | LVIF_PARAM;
  101. INT nIndex =0;
  102. #if 0
  103. // Get the component's class image list index
  104. if (pcild)
  105. {
  106. hr = HrSetupDiGetClassImageIndex(pcild, &guidClass, &nIndex);
  107. TraceError("HrSetupDiGetClassImageIndex failed.", hr);
  108. lvi.iImage = nIndex;
  109. hr = S_OK;
  110. }
  111. lvi.iItem = *pnPos;
  112. #endif
  113. lvi.iItem = 0;
  114. #if 0
  115. NET_ITEM_DATA * pnid = new NET_ITEM_DATA;
  116. pnid->szwName = SzDupSz(pszwName);
  117. pnid->szwDesc = SzDupSz(pszwDesc);
  118. pnid->dwFlags = dwFlags;
  119. AddRefObj(pnid->pncc = pncc);
  120. pnid->pCompObj = new CComponentObj(pncc);
  121. hr = pnid->pCompObj->HrInit(plistBindingPaths);
  122. if FAILED(hr)
  123. {
  124. TraceError("HrInsertComponent: failed to initialize a component object", hr);
  125. hr = S_OK;
  126. }
  127. lvi.lParam = reinterpret_cast<LPARAM>(pnid);
  128. lvi.pszText = pnid->szwName;
  129. #endif
  130. lvi.lParam = 0;
  131. lvi.pszText = L"Hey, Jude";
  132. // We will refresh the state of the whole list in the end
  133. UINT iChkIndex = SELS_CHECKED;
  134. lvi.state = INDEXTOSTATEIMAGEMASK( iChkIndex );
  135. INT ret;
  136. ret = ListView_InsertItem(m_hwndLV, &lvi);
  137. return TRUE;
  138. }
  139. //+---------------------------------------------------------------------------
  140. //
  141. // Member: CDbgFlagPage::OnHelp
  142. //
  143. // Purpose: Handles the WM_HELP message.
  144. //
  145. // Arguments:
  146. // uMsg []
  147. // wParam []
  148. // lParam []
  149. // bHandled []
  150. //
  151. // Returns: TRUE
  152. //
  153. // Author: danielwe 25 Feb 1998
  154. //
  155. // Notes:
  156. //
  157. LRESULT CDbgFlagPage::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam,
  158. BOOL& bHandled)
  159. {
  160. OnTraceHelpGeneric(m_hWnd, lParam);
  161. return TRUE;
  162. }
  163. //+---------------------------------------------------------------------------
  164. //
  165. // Member: CDbgFlagPage::OnDestroy
  166. //
  167. // Purpose: Called when the dialog page is destroyed
  168. //
  169. // Arguments:
  170. // uMsg []
  171. // wParam []
  172. // lParam []
  173. // bHandled []
  174. //
  175. // Returns:
  176. //
  177. // Author: danielwe 2 Feb 1998
  178. //
  179. // Notes:
  180. //
  181. LRESULT CDbgFlagPage::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam,
  182. BOOL& bHandled)
  183. {
  184. UninitTraceListView(m_hwndLV);
  185. return 0;
  186. }
  187. //+---------------------------------------------------------------------------
  188. //
  189. // Member: CDbgFlagPage::OnSetCursor
  190. //
  191. // Purpose: Called in response to the WM_SETCURSOR message
  192. //
  193. // Arguments:
  194. // uMsg []
  195. // wParam []
  196. // lParam []
  197. // bHandled []
  198. //
  199. // Returns:
  200. //
  201. // Author: danielwe 2 Jan 1998
  202. //
  203. // Notes:
  204. //
  205. LRESULT CDbgFlagPage::OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam,
  206. BOOL& bHandled)
  207. {
  208. if (m_hPrevCurs)
  209. {
  210. if (LOWORD(lParam) == HTCLIENT)
  211. {
  212. SetCursor(LoadCursor(NULL, IDC_WAIT));
  213. }
  214. return TRUE;
  215. }
  216. return 0;
  217. }
  218. //+---------------------------------------------------------------------------
  219. //
  220. // Member: CDbgFlagPage::OnAdd
  221. //
  222. // Purpose: Handles the clicking of the Add button
  223. //
  224. // Arguments:
  225. // wNotifyCode []
  226. // wID []
  227. // hWndCtl []
  228. // bHandled []
  229. //
  230. // Returns:
  231. //
  232. // Author: danielwe 29 Oct 1997
  233. //
  234. // Notes:
  235. //
  236. LRESULT CDbgFlagPage::OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  237. BOOL& bHandled)
  238. {
  239. HRESULT hr = S_OK;
  240. #if 0
  241. hr = HrLvAdd(m_hwndLV, m_hWnd, m_pnc, m_pnccAdapter, &m_listBindingPaths);
  242. if (SUCCEEDED(hr) && (S_FALSE != hr))
  243. {
  244. // Change the Cancel Button to CLOSE (because we committed changes)
  245. //
  246. ::PostMessage(GetParent(), PSM_CANCELTOCLOSE, 0, 0L);
  247. }
  248. if (NETCFG_S_REBOOT == hr)
  249. {
  250. RequestReboot();
  251. // The reboot request has been handled
  252. hr = S_OK;
  253. }
  254. TraceError("CDbgFlagPage::OnAdd", hr);
  255. #endif
  256. return LresFromHr(hr);
  257. }
  258. //+---------------------------------------------------------------------------
  259. //
  260. // Member: CDbgFlagPage::OnRemove
  261. //
  262. // Purpose: Handles the clicking of the Remove button
  263. //
  264. // Arguments:
  265. // wNotifyCode []
  266. // wID []
  267. // hWndCtl []
  268. // bHandled []
  269. //
  270. // Returns:
  271. //
  272. // Author: danielwe 29 Oct 1997
  273. //
  274. // Notes:
  275. //
  276. LRESULT CDbgFlagPage::OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  277. BOOL& bHandled)
  278. {
  279. HRESULT hr = S_OK;
  280. #if 0
  281. hr = HrLvRemove(m_hwndLV, m_hWnd, m_pnc, m_pnccAdapter,
  282. &m_listBindingPaths);
  283. // if list is empty, reset the buttons
  284. if (0 == ListView_GetItemCount(m_hwndLV))
  285. {
  286. // Reset the buttons and the description text based on the changed selection
  287. LvSetButtons(m_handles);
  288. }
  289. if (SUCCEEDED(hr) && (S_FALSE != hr))
  290. {
  291. // Change the Cancel Button to CLOSE (because we committed changes)
  292. //
  293. ::PostMessage(GetParent(), PSM_CANCELTOCLOSE, 0, 0L);
  294. }
  295. if (NETCFG_S_REBOOT == hr)
  296. {
  297. RequestReboot();
  298. // The reboot request has been handled
  299. hr = S_OK;
  300. }
  301. TraceError("CDbgFlagPage::OnRemove", hr);
  302. #endif
  303. return LresFromHr(hr);
  304. }
  305. //+---------------------------------------------------------------------------
  306. //
  307. // Member: CDbgFlagPage::OnProperties
  308. //
  309. // Purpose: Handles the clicking of the Properties button
  310. //
  311. // Arguments:
  312. // wNotifyCode []
  313. // wID []
  314. // hWndCtl []
  315. // bHandled []
  316. //
  317. // Returns:
  318. //
  319. // Author: danielwe 29 Oct 1997
  320. //
  321. // Notes:
  322. //
  323. LRESULT CDbgFlagPage::OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  324. BOOL& bHandled)
  325. {
  326. HRESULT hr = S_OK;
  327. #if 0
  328. hr = HrLvProperties(m_hwndLV, m_hWnd, m_pnc, m_punk,
  329. m_pnccAdapter, &m_listBindingPaths);
  330. TraceError("CDbgFlagPage::OnProperties", hr);
  331. #endif
  332. return LresFromHr(hr);
  333. }
  334. //+---------------------------------------------------------------------------
  335. //
  336. // Member: CDbgFlagPage::OnApply
  337. //
  338. // Purpose: Called when the Networking page is applied
  339. //
  340. // Arguments:
  341. // idCtrl []
  342. // pnmh []
  343. // bHandled []
  344. //
  345. // Returns:
  346. //
  347. // Author: danielwe 29 Oct 1997
  348. //
  349. // Notes:
  350. //
  351. LRESULT CDbgFlagPage::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  352. {
  353. HRESULT hr = S_OK;
  354. #if 0
  355. if (m_fReentrancyCheck)
  356. {
  357. TraceTag(ttidLanUi, "CDbgFlagPage::OnApply is being re-entered! "
  358. "I'm outta here!");
  359. // Don't allow the automatic EndDialog() to work just yet
  360. SetWindowLong(DWLP_MSGRESULT, PSNRET_INVALID);
  361. return TRUE;
  362. }
  363. m_hPrevCurs = SetCursor(LoadCursor(NULL, IDC_WAIT));
  364. hr = m_pnc->Validate();
  365. if (hr == S_OK)
  366. {
  367. BOOL fReboot = FALSE;
  368. // Note: This function becomes reentrant because INetCfg::Apply()
  369. // has a message pump in it which causes the PSN_APPLY message to
  370. // be processed twice. This will happen ONLY if the user double-clicks
  371. // the OK button.
  372. m_fReentrancyCheck = TRUE;
  373. TraceTag(ttidLanUi, "Calling INetCfg::Apply()");
  374. hr = m_pnc->Apply();
  375. if (NETCFG_S_REBOOT == hr)
  376. {
  377. fReboot = TRUE;
  378. }
  379. if (SUCCEEDED(hr))
  380. {
  381. TraceTag(ttidLanUi, "INetCfg::Apply() succeeded");
  382. hr = m_pnc->Uninitialize();
  383. }
  384. if (SUCCEEDED(hr))
  385. {
  386. if (m_fRebootAlreadyRequested || fReboot)
  387. {
  388. DWORD dwFlags = QUFR_REBOOT;
  389. if (!m_fRebootAlreadyRequested)
  390. dwFlags |= QUFR_PROMPT;
  391. (VOID) HrNcQueryUserForReboot(_Module.GetResourceInstance(),
  392. m_hWnd, IDS_LAN_CAPTION,
  393. IDS_REBOOT_REQUIRED,
  394. dwFlags);
  395. }
  396. }
  397. }
  398. // Apply "general" properties
  399. //
  400. if (SUCCEEDED(hr))
  401. {
  402. LANCON_INFO linfo = {0};
  403. linfo.fShowIcon = IsDlgButtonChecked(IDC_CHK_ShowIcon);
  404. // Set new value of show icon property
  405. hr = m_plan->SetInfo(LCIF_ICON, &linfo);
  406. }
  407. // Normalize result
  408. if (S_FALSE == hr)
  409. {
  410. hr = S_OK;
  411. }
  412. if (m_hPrevCurs)
  413. {
  414. SetCursor(m_hPrevCurs);
  415. m_hPrevCurs = NULL;
  416. }
  417. // Reset this just in case
  418. m_fReentrancyCheck = FALSE;
  419. TraceError("CDbgFlagPage::OnApply", hr);
  420. #endif
  421. return LresFromHr(hr);
  422. }
  423. //+---------------------------------------------------------------------------
  424. //
  425. // Member: CDbgFlagPage::OnCancel
  426. //
  427. // Purpose: Called when the Networking page is cancelled.
  428. //
  429. // Arguments:
  430. // idCtrl []
  431. // pnmh []
  432. // bHandled []
  433. //
  434. // Returns:
  435. //
  436. // Author: danielwe 3 Jan 1998
  437. //
  438. // Notes:
  439. //
  440. LRESULT CDbgFlagPage::OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  441. {
  442. HRESULT hr = S_OK;
  443. #if 0
  444. AssertSz(m_pnc, "I need a NetCfg object!");
  445. hr = m_pnc->Uninitialize();
  446. TraceError("CDbgFlagPage::OnCancel", hr);
  447. #endif
  448. return LresFromHr(hr);
  449. }
  450. //+---------------------------------------------------------------------------
  451. //
  452. // Member: CDbgFlagPage::OnDeleteItem
  453. //
  454. // Purpose: Called when the LVN_DELETEITEM message is received
  455. //
  456. // Arguments:
  457. // idCtrl []
  458. // pnmh []
  459. // bHandled []
  460. //
  461. // Returns:
  462. //
  463. // Author: danielwe 3 Nov 1997
  464. //
  465. // Notes:
  466. //
  467. LRESULT CDbgFlagPage::OnDeleteItem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  468. {
  469. NM_LISTVIEW * pnmlv = reinterpret_cast<NM_LISTVIEW *>(pnmh);
  470. #if 0
  471. LvDeleteItem(m_hwndLV, pnmlv->iItem);
  472. #endif
  473. return 0;
  474. }
  475. //+---------------------------------------------------------------------------
  476. //
  477. // Member: CDbgFlagPage::OnClick
  478. //
  479. // Purpose: Called in response to the NM_CLICK message
  480. //
  481. // Arguments:
  482. // idCtrl []
  483. // pnmh []
  484. // fHandled []
  485. //
  486. // Returns:
  487. //
  488. // Author: danielwe 1 Dec 1997
  489. //
  490. // Notes:
  491. //
  492. LRESULT CDbgFlagPage::OnClick(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  493. {
  494. #if 0
  495. OnListClick(m_hwndLV, m_hWnd, m_pnc, m_punk,
  496. m_pnccAdapter, &m_listBindingPaths, FALSE);
  497. #endif
  498. return 0;
  499. }
  500. //+---------------------------------------------------------------------------
  501. //
  502. // Member: CDbgFlagPage::OnDbClick
  503. //
  504. // Purpose: Called in response to the NM_DBLCLK message
  505. //
  506. // Arguments:
  507. // idCtrl []
  508. // pnmh []
  509. // fHandled []
  510. //
  511. // Returns:
  512. //
  513. // Author: danielwe 1 Dec 1997
  514. //
  515. // Notes:
  516. //
  517. LRESULT CDbgFlagPage::OnDbClick(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  518. {
  519. #if 0
  520. OnListClick(m_hwndLV, m_hWnd, m_pnc, m_punk,
  521. m_pnccAdapter, &m_listBindingPaths, TRUE);
  522. #endif
  523. return 0;
  524. }
  525. //+---------------------------------------------------------------------------
  526. //
  527. // Member: CDbgFlagPage::OnKeyDown
  528. //
  529. // Purpose: Called in response to the LVN_KEYDOWN message
  530. //
  531. // Arguments:
  532. // idCtrl []
  533. // pnmh []
  534. // fHandled []
  535. //
  536. // Returns:
  537. //
  538. // Author: danielwe 1 Dec 1997
  539. //
  540. // Notes:
  541. //
  542. LRESULT CDbgFlagPage::OnKeyDown(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  543. {
  544. LV_KEYDOWN* plvkd = (LV_KEYDOWN*)pnmh;
  545. #if 0
  546. OnListKeyDown(m_hwndLV, &m_listBindingPaths, plvkd->wVKey);
  547. #endif
  548. return 0;
  549. }
  550. //+---------------------------------------------------------------------------
  551. //
  552. // Member: CDbgFlagPage::OnItemChanged
  553. //
  554. // Purpose: Called when the LVN_ITEMCHANGED message is received
  555. //
  556. // Arguments:
  557. // idCtrl []
  558. // pnmh []
  559. // bHandled []
  560. //
  561. // Returns:
  562. //
  563. // Author: danielwe 10 Nov 1997
  564. //
  565. // Notes:
  566. //
  567. LRESULT CDbgFlagPage::OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  568. {
  569. NM_LISTVIEW * pnmlv = reinterpret_cast<NM_LISTVIEW *>(pnmh);
  570. #if 0
  571. HANDLES handles;
  572. Assert(pnmlv);
  573. // Reset the buttons and the description text based on the changed selection
  574. LvSetButtons(m_handles);
  575. #endif
  576. return 0;
  577. }
  578. #endif // ENABLETRACE