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.

73 lines
1.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Declares the class HiddenDialogWithWorker.
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include <proxypch.h>
  11. #include <hiddenworker.h>
  12. HiddenDialogWithWorker::HiddenDialogWithWorker()
  13. : worker(0)
  14. {
  15. }
  16. HiddenDialogWithWorker::~HiddenDialogWithWorker() throw ()
  17. {
  18. if (worker != 0)
  19. {
  20. WaitForSingleObject(worker, INFINITE);
  21. CloseHandle(worker);
  22. }
  23. }
  24. void HiddenDialogWithWorker::Start()
  25. {
  26. if (!Create(IDD_HIDDEN_WORKER))
  27. {
  28. AfxThrowLastError();
  29. }
  30. }
  31. BOOL HiddenDialogWithWorker::OnInitDialog()
  32. {
  33. worker = CreateThread(0, 0, StartRoutine, this, 0, 0);
  34. if (worker == 0)
  35. {
  36. AfxThrowLastError();
  37. }
  38. return CDialog::OnInitDialog();
  39. }
  40. LRESULT HiddenDialogWithWorker::OnThreadMessage(WPARAM wParam, LPARAM lParam)
  41. {
  42. DestroyWindow();
  43. OnComplete(lParam);
  44. return 0;
  45. }
  46. BEGIN_MESSAGE_MAP(HiddenDialogWithWorker, CDialog)
  47. ON_MESSAGE(threadMessage, OnThreadMessage)
  48. END_MESSAGE_MAP()
  49. DWORD WINAPI HiddenDialogWithWorker::StartRoutine(void* arg) throw ()
  50. {
  51. HiddenDialogWithWorker* obj = static_cast<HiddenDialogWithWorker*>(arg);
  52. LPARAM result = obj->DoWork();
  53. obj->PostMessage(threadMessage, 0, result);
  54. return NO_ERROR;
  55. }