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.

176 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. irunobj.cpp
  5. Abstract:
  6. Implementation of the IRunnableObject interface which allows
  7. the control to enter the "running" state which means Sysmon's
  8. dialog box is created, but not visible. This is necessary so
  9. that containers can ask for our extents before calling DoVerb.
  10. --*/
  11. #include "polyline.h"
  12. #include "unkhlpr.h"
  13. /*
  14. * CImpIRunnableObject interface implementation
  15. */
  16. IMPLEMENT_CONTAINED_INTERFACE(CPolyline, CImpIRunnableObject)
  17. /*
  18. * CImpIRunnableObject::GetRunningClass
  19. *
  20. * Purpose:
  21. * Returns the CLSID of the object.
  22. *
  23. * Parameters:
  24. * pClsID LPCLSID in which to store the CLSID.
  25. *
  26. * Return Value:
  27. * HRESULT NOERROR or a general error value.
  28. */
  29. STDMETHODIMP CImpIRunnableObject::GetRunningClass(LPCLSID pClsID)
  30. {
  31. HRESULT hr = S_OK;
  32. if (pClsID == NULL) {
  33. return E_POINTER;
  34. }
  35. try {
  36. *pClsID = m_pObj->m_clsID;
  37. } catch (...) {
  38. hr = E_POINTER;
  39. }
  40. return hr;
  41. }
  42. /*
  43. * CImpIRunnableObject::Run
  44. *
  45. * Purpose:
  46. * Run an object in the given bind context, that is, put the object
  47. * into the running state.
  48. *
  49. * Parameters:
  50. * pBindCtx LPBINDCTX of the bind context to use.
  51. *
  52. * Return Value:
  53. * HRESULT NOERROR or a general error value.
  54. */
  55. STDMETHODIMP CImpIRunnableObject::Run(LPBINDCTX /* pBindCtx */)
  56. {
  57. /*
  58. * Registration of the object as running happens in
  59. * IOleObject::SetClientSite since we need a moniker from
  60. * the container and we don't have a client site pointer yet.
  61. */
  62. RECT rc;
  63. HRESULT hr = NOERROR;
  64. if (!m_pObj->m_bIsRunning) {
  65. SetRect(&rc,0,0,150,150);
  66. #ifdef USE_SAMPLE_IPOLYLIN10
  67. hr = m_pObj->m_pImpIPolyline->Init(g_hWndFoster,
  68. &rc,
  69. WS_CHILD | WS_VISIBLE,
  70. ID_POLYLINE);
  71. #else
  72. hr = m_pObj->m_pCtrl->Init(g_hWndFoster);
  73. #endif
  74. if ( SUCCEEDED ( hr ) ) {
  75. m_pObj->m_bIsRunning = TRUE;
  76. }
  77. }
  78. return hr;
  79. }
  80. /*
  81. * CImpIRunnableObject::IsRunning
  82. *
  83. * Purpose:
  84. * Answers whether an object is currently in the running state.
  85. *
  86. * Parameters:
  87. * None
  88. *
  89. * Return Value:
  90. * BOOL Indicates the running state of the object.
  91. */
  92. STDMETHODIMP_(BOOL) CImpIRunnableObject::IsRunning(void)
  93. {
  94. return m_pObj->m_bIsRunning;
  95. }
  96. /*
  97. * CImpIRunnableObject::LockRunning
  98. *
  99. * Purpose:
  100. * Locks an already running object into the running state or unlocks
  101. * it from such a state.
  102. *
  103. * Parameters:
  104. * fLock BOOL indicating lock (TRUE) or unlock
  105. * (FALSE)
  106. * fLastUnlockCloses BOOL indicating if the last call to this
  107. * function with fLock==FALSE closes the
  108. * object.
  109. *
  110. * Return Value:
  111. * HRESULT NOERROR or a general error value.
  112. */
  113. STDMETHODIMP CImpIRunnableObject::LockRunning(
  114. BOOL fLock,
  115. BOOL fLastUnlockCloses
  116. )
  117. {
  118. //Calling CoLockObjectExternal is all we have to do here.
  119. return CoLockObjectExternal(this, fLock, fLastUnlockCloses);
  120. }
  121. /*
  122. * CImpIRunnableObject::SetContainedObject
  123. *
  124. * Purpose:
  125. * Informs the object (embedded object) that it is inside a
  126. * compound document container.
  127. *
  128. * Parameters:
  129. * fContained BOOL indicating if the object is now contained.
  130. *
  131. * Return Value:
  132. * HRESULT NOERROR or a general error value.
  133. */
  134. STDMETHODIMP CImpIRunnableObject::SetContainedObject(BOOL /* fContained */)
  135. {
  136. //We can ignore this.
  137. return NOERROR;
  138. }