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.

157 lines
3.3 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. *pClsID=m_pObj->m_clsID;
  32. return NOERROR;
  33. }
  34. /*
  35. * CImpIRunnableObject::Run
  36. *
  37. * Purpose:
  38. * Run an object in the given bind context, that is, put the object
  39. * into the running state.
  40. *
  41. * Parameters:
  42. * pBindCtx LPBINDCTX of the bind context to use.
  43. *
  44. * Return Value:
  45. * HRESULT NOERROR or a general error value.
  46. */
  47. STDMETHODIMP CImpIRunnableObject::Run(LPBINDCTX /* pBindCtx */)
  48. {
  49. /*
  50. * Registration of the object as running happens in
  51. * IOleObject::SetClientSite since we need a moniker from
  52. * the container and we don't have a client site pointer yet.
  53. */
  54. RECT rc;
  55. HRESULT hr = NOERROR;
  56. if (!m_pObj->m_bIsRunning) {
  57. SetRect(&rc,0,0,150,150);
  58. hr = m_pObj->m_pImpIPolyline->Init(g_hWndFoster, &rc, WS_CHILD | WS_VISIBLE,
  59. ID_POLYLINE);
  60. if ( SUCCEEDED ( hr ) ) {
  61. m_pObj->m_bIsRunning = TRUE;
  62. }
  63. }
  64. return hr;
  65. }
  66. /*
  67. * CImpIRunnableObject::IsRunning
  68. *
  69. * Purpose:
  70. * Answers whether an object is currently in the running state.
  71. *
  72. * Parameters:
  73. * None
  74. *
  75. * Return Value:
  76. * BOOL Indicates the running state of the object.
  77. */
  78. STDMETHODIMP_(BOOL) CImpIRunnableObject::IsRunning(void)
  79. {
  80. return m_pObj->m_bIsRunning;
  81. }
  82. /*
  83. * CImpIRunnableObject::LockRunning
  84. *
  85. * Purpose:
  86. * Locks an already running object into the running state or unlocks
  87. * it from such a state.
  88. *
  89. * Parameters:
  90. * fLock BOOL indicating lock (TRUE) or unlock
  91. * (FALSE)
  92. * fLastUnlockCloses BOOL indicating if the last call to this
  93. * function with fLock==FALSE closes the
  94. * object.
  95. *
  96. * Return Value:
  97. * HRESULT NOERROR or a general error value.
  98. */
  99. STDMETHODIMP CImpIRunnableObject::LockRunning(BOOL fLock
  100. , BOOL fLastUnlockCloses)
  101. {
  102. //Calling CoLockObjectExternal is all we have to do here.
  103. return CoLockObjectExternal(this, fLock, fLastUnlockCloses);
  104. }
  105. /*
  106. * CImpIRunnableObject::SetContainedObject
  107. *
  108. * Purpose:
  109. * Informs the object (embedded object) that it is inside a
  110. * compound document container.
  111. *
  112. * Parameters:
  113. * fContained BOOL indicating if the object is now contained.
  114. *
  115. * Return Value:
  116. * HRESULT NOERROR or a general error value.
  117. */
  118. STDMETHODIMP CImpIRunnableObject::SetContainedObject(BOOL /* fContained */)
  119. {
  120. //We can ignore this.
  121. return NOERROR;
  122. }