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.

171 lines
3.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: cloop.cxx
  7. //
  8. // Contents: implementations for CBall
  9. //
  10. // Functions:
  11. // CLoop::CLoop
  12. // CLoop::~CLoop
  13. // CLoop::QueryInterface
  14. //
  15. // History: 06-Aug-92 Ricksa Created
  16. //
  17. //--------------------------------------------------------------------------
  18. #include <pch.cxx>
  19. #pragma hdrstop
  20. #include <cloop.hxx> // class definition
  21. //+-------------------------------------------------------------------------
  22. //
  23. // Method: CLoop::CLoop
  24. //
  25. // Synopsis: Creates the application window
  26. //
  27. // Arguments: [pisb] - ISysBind instance
  28. //
  29. // History: 06-Aug-92 Ricksa Created
  30. //
  31. //--------------------------------------------------------------------------
  32. CLoop::CLoop(void)
  33. : _pRemoteLoop(NULL)
  34. {
  35. GlobalRefs(TRUE);
  36. ENLIST_TRACKING(CLoop);
  37. }
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Method: CLoop::~CLoop
  41. //
  42. // Synopsis: Cleans up object
  43. //
  44. // History: 06-Aug-92 Ricksa Created
  45. //
  46. //--------------------------------------------------------------------------
  47. CLoop::~CLoop(void)
  48. {
  49. if (_pRemoteLoop)
  50. {
  51. _pRemoteLoop->Release();
  52. }
  53. GlobalRefs(FALSE);
  54. }
  55. //+-------------------------------------------------------------------------
  56. //
  57. // Method: CLoop::QueryInterface
  58. //
  59. // Synopsis: Gets called when a WM_COMMAND message received.
  60. //
  61. // Arguments: [ifid] - interface instance requested
  62. // [ppunk] - where to put pointer to interface instance
  63. //
  64. // Returns: S_OK or ERROR_BAD_COMMAND
  65. //
  66. // History: 06-Aug-92 Ricksa Created
  67. //
  68. //--------------------------------------------------------------------------
  69. STDMETHODIMP CLoop::QueryInterface(REFIID riid, void **ppunk)
  70. {
  71. SCODE sc = E_NOINTERFACE;
  72. *ppunk = NULL;
  73. if (IsEqualIID(riid,IID_IUnknown) ||
  74. IsEqualIID(riid,IID_ILoop))
  75. {
  76. // Increase the reference count
  77. *ppunk = (void *)(ILoop *) this;
  78. AddRef();
  79. // Set to success
  80. sc = S_OK;
  81. }
  82. return sc;
  83. }
  84. //+-------------------------------------------------------------------------
  85. //
  86. // Method: CLoop::Init
  87. //
  88. // Synopsis:
  89. //
  90. // Arguments:
  91. //
  92. // Returns: S_OK or ERROR_BAD_COMMAND
  93. //
  94. // History: 06-Aug-92 Ricksa Created
  95. //
  96. //--------------------------------------------------------------------------
  97. STDMETHODIMP CLoop::Init(ILoop *pRemoteLoop)
  98. {
  99. _pRemoteLoop = pRemoteLoop;
  100. _pRemoteLoop->AddRef();
  101. // Format message for the screen
  102. Display(TEXT("Loop Init %ld\n"), pRemoteLoop);
  103. return S_OK;
  104. }
  105. //+-------------------------------------------------------------------------
  106. //
  107. // Function: CLoop::Uninit
  108. //
  109. // Synopsis:
  110. //
  111. // Arguments:
  112. //
  113. // Returns: S_OK
  114. //
  115. // History: 06-Aug-92 Ricksa Created
  116. //
  117. //--------------------------------------------------------------------------
  118. STDMETHODIMP CLoop::Uninit(void)
  119. {
  120. // Format message for the screen
  121. Display(TEXT("Uninit %ld\n"), _pRemoteLoop);
  122. if (_pRemoteLoop)
  123. {
  124. _pRemoteLoop->Release();
  125. _pRemoteLoop = NULL;
  126. }
  127. return S_OK;
  128. }
  129. //+-------------------------------------------------------------------------
  130. //
  131. // Function: CLoop::Loop
  132. //
  133. // Synopsis:
  134. //
  135. // Arguments:
  136. //
  137. // Returns: S_OK
  138. //
  139. // History: 06-Aug-92 Ricksa Created
  140. //
  141. //--------------------------------------------------------------------------
  142. STDMETHODIMP CLoop::Loop(ULONG ulLoopCount)
  143. {
  144. // Format message for the screen
  145. Display(TEXT("Loop Count = %ld\n"), ulLoopCount);
  146. if (--ulLoopCount == 0)
  147. return S_OK;
  148. else
  149. return _pRemoteLoop->Loop(ulLoopCount);
  150. }