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.

97 lines
2.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: ownthreaddialog.h
  8. //
  9. //--------------------------------------------------------------------------
  10. void CreateNewStatisticsWindow(StatsDialog *pWndStats,
  11. HWND hWndParent,
  12. UINT nIDD)
  13. {
  14. ModelessThread * pMT;
  15. // If the dialog is still up, don't create a new one
  16. if (pWndStats->GetSafeHwnd())
  17. {
  18. ::SetActiveWindow(pWndStats->GetSafeHwnd());
  19. return;
  20. }
  21. pMT = new ModelessThread(hWndParent,
  22. nIDD,
  23. pWndStats->GetSignalEvent(),
  24. pWndStats);
  25. pMT->CreateThread();
  26. }
  27. void WaitForStatisticsWindow(StatsDialog *pWndStats)
  28. {
  29. if (pWndStats->GetSafeHwnd())
  30. {
  31. // Post a cancel to that window
  32. // Do an explicit post so that it executes on the other thread
  33. pWndStats->PostMessage(WM_COMMAND, IDCANCEL, 0);
  34. // Now we need to wait for the event to be signalled so that
  35. // its memory can be cleaned up
  36. WaitForSingleObject(pWndStats->GetSignalEvent(), INFINITE);
  37. }
  38. }
  39. void StatsDialog::PostRefresh()
  40. {
  41. if (GetSafeHwnd())
  42. PostMessage(WM_COMMAND, IDC_STATSDLG_BTN_REFRESH);
  43. }
  44. void StatsDialog::OnCancel()
  45. {
  46. DeleteAllItems();
  47. DestroyWindow();
  48. // Explicitly kill this thread.
  49. AfxPostQuitMessage(0);
  50. }
  51. StatsDialog::~StatsDialog()
  52. {
  53. if (m_hEventThreadKilled)
  54. ::CloseHandle(m_hEventThreadKilled);
  55. m_hEventThreadKilled = 0;
  56. }
  57. StatsDialog::StatsDialog(DWORD dwOptions) :
  58. m_dwOptions(dwOptions),
  59. m_ulId(0),
  60. m_pConfig(NULL),
  61. m_bAfterInitDialog(FALSE),
  62. m_fSortDirection(0)
  63. {
  64. m_sizeMinimum.cx = m_sizeMinimum.cy = 0;
  65. m_hEventThreadKilled = ::CreateEvent(NULL, FALSE, FALSE, NULL);
  66. Assert(m_hEventThreadKilled);
  67. // Initialize the array of buttons
  68. ::ZeroMemory(m_rgBtn, sizeof(m_rgBtn));
  69. m_rgBtn[INDEX_CLOSE].m_ulId = IDCANCEL;
  70. m_rgBtn[INDEX_REFRESH].m_ulId = IDC_STATSDLG_BTN_REFRESH;
  71. m_rgBtn[INDEX_SELECT].m_ulId = IDC_STATSDLG_BTN_SELECT_COLUMNS;
  72. }