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.

112 lines
2.5 KiB

  1. // Copyright (C) 1993-1997 Microsoft Corporation. All rights reserved.
  2. #include "header.h"
  3. #include "resource.h"
  4. #include "lockout.h"
  5. #include "userwait.h"
  6. #include "cdlg.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. // class constructor
  12. //
  13. CUWait::CUWait(HWND hwndParent)
  14. {
  15. m_hwndParent = hwndParent;
  16. m_hwndUWait = NULL;
  17. m_bVisable = FALSE;
  18. m_bUserCancel = FALSE;
  19. // create the thread
  20. //
  21. LPCTSTR lpDialogTemplate = MAKEINTRESOURCE(IDD_SEARCH_CANCEL);
  22. m_LockOut.LockOut(hwndParent);
  23. if(g_bWinNT5)
  24. {
  25. CreateDialogParamW(_Module.GetResourceInstance(), MAKEINTRESOURCEW(IDD_SEARCH_CANCEL), m_hwndParent,
  26. (DLGPROC) CWaitDlgProc, (LPARAM) this);
  27. }
  28. else
  29. {
  30. CreateDialogParam(_Module.GetResourceInstance(), lpDialogTemplate, m_hwndParent,
  31. (DLGPROC) CWaitDlgProc, (LPARAM) this);
  32. }
  33. if(!IsValidWindow(m_hwndUWait))
  34. m_LockOut.Unlock();
  35. if(IsValidWindow(m_hwndUWait))
  36. ShowWindow(m_hwndUWait, SW_SHOW);
  37. MSG msg;
  38. int iCount = 256;
  39. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) && iCount--)
  40. {
  41. TranslateMessage(&msg);
  42. DispatchMessage(&msg);
  43. }
  44. }
  45. // class destructor
  46. //
  47. CUWait::~CUWait()
  48. {
  49. // destroy the dialog
  50. //
  51. if(m_hwndUWait)
  52. SendMessage(m_hwndUWait, WM_CLOSE, 0, 0);
  53. if (IsValidWindow(m_hwndUWait))
  54. DestroyWindow(m_hwndUWait);
  55. }
  56. // Dialog procedure for search cancel dialog
  57. //
  58. BOOL CALLBACK CWaitDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
  59. {
  60. CUWait* pUWait = (CUWait*) GetWindowLongPtr(hdlg, GWLP_USERDATA);
  61. switch (msg) {
  62. case WM_INITDIALOG:
  63. pUWait = (CUWait*) lParam;
  64. SetWindowLongPtr(hdlg, GWLP_USERDATA, lParam);
  65. pUWait->m_hwndUWait = hdlg;
  66. CenterWindow(pUWait->m_hwndParent, hdlg);
  67. SetWindowPos(hdlg, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  68. return TRUE;
  69. case WM_COMMAND:
  70. {
  71. switch (LOWORD(wParam))
  72. {
  73. case IDCANCEL:
  74. EnableWindow(GetDlgItem(hdlg,IDCANCEL),FALSE);
  75. pUWait->m_bUserCancel = TRUE;
  76. break;
  77. }
  78. }
  79. break;
  80. case WM_CLOSE:
  81. pUWait->m_bUserCancel = TRUE;
  82. pUWait->m_LockOut.Unlock();
  83. EndDialog(hdlg, FALSE);
  84. break;
  85. default:
  86. return FALSE;
  87. }
  88. return FALSE;
  89. }