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.

153 lines
3.7 KiB

  1. #include "privcpp.h"
  2. const DWORD g_cookie = 111176;
  3. //
  4. // IViewObject2 Methods...
  5. //
  6. HRESULT CPackage::Draw(DWORD dwDrawAspect, LONG lindex,
  7. LPVOID pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw,
  8. LPCRECTL lprcBounds, LPCRECTL lprcWBounds,BOOL (CALLBACK *pfnContinue)(ULONG_PTR),
  9. ULONG_PTR dwContinue)
  10. {
  11. DebugMsg(DM_TRACE,"pack vo - Draw() called.");
  12. _IconDraw(_lpic, hdcDraw, (RECT *)lprcBounds);
  13. return S_OK;
  14. }
  15. HRESULT CPackage::GetColorSet(DWORD dwAspect, LONG lindex,
  16. LPVOID pvAspect, DVTARGETDEVICE *ptd,
  17. HDC hdcTargetDev, LPLOGPALETTE *ppColorSet)
  18. {
  19. HRESULT hr = S_FALSE;
  20. DebugMsg(DM_TRACE,"pack vo - GetColorSet() called.");
  21. if (ppColorSet == NULL)
  22. hr = E_INVALIDARG;
  23. else
  24. *ppColorSet = NULL; // null the out param
  25. return hr;
  26. }
  27. HRESULT CPackage::Freeze(DWORD dwDrawAspect, LONG lindex,
  28. LPVOID pvAspect, LPDWORD pdwFreeze)
  29. {
  30. HRESULT hr = S_OK;
  31. DebugMsg(DM_TRACE,"pack vo - Freeze() called.");
  32. if (pdwFreeze == NULL)
  33. hr = E_INVALIDARG;
  34. else
  35. {
  36. if (_fFrozen)
  37. {
  38. *pdwFreeze = g_cookie;
  39. }
  40. else
  41. {
  42. //
  43. // This is where we would take a snapshot of the icon to use as
  44. // the "frozen" image in subsequent routines. For now, we just
  45. // return the cookie. Draw() will use the current icon regardless
  46. // of the fFrozen flag.
  47. //
  48. _fFrozen = TRUE;
  49. *pdwFreeze = g_cookie;
  50. }
  51. }
  52. return hr;
  53. }
  54. HRESULT CPackage::Unfreeze(DWORD dwFreeze)
  55. {
  56. HRESULT hr = S_OK;
  57. DebugMsg(DM_TRACE,"pack vo - Unfreeze() called.");
  58. // If the pass us an invalid cookie or we're not frozen then bail
  59. if (dwFreeze != g_cookie || !_fFrozen)
  60. hr = OLE_E_NOCONNECTION;
  61. else
  62. {
  63. //
  64. // This is where we'd get rid of the frozen presentation we saved in
  65. // IViewObject::Freeze().
  66. //
  67. _fFrozen = FALSE;
  68. }
  69. return hr;
  70. }
  71. HRESULT CPackage::SetAdvise(DWORD dwAspects, DWORD dwAdvf,
  72. LPADVISESINK pAdvSink)
  73. {
  74. DebugMsg(DM_TRACE,"pack vo - SetAdvise() called.");
  75. if (_pViewSink)
  76. _pViewSink->Release();
  77. _pViewSink = pAdvSink;
  78. _dwViewAspects = dwAspects;
  79. _dwViewAdvf = dwAdvf;
  80. if (_pViewSink)
  81. _pViewSink->AddRef();
  82. return S_OK;
  83. }
  84. HRESULT CPackage::GetAdvise(LPDWORD pdwAspects, LPDWORD pdwAdvf,
  85. LPADVISESINK *ppAdvSink)
  86. {
  87. HRESULT hr = S_OK;
  88. DebugMsg(DM_TRACE,"pack vo - GetAdvise() called.");
  89. if (!ppAdvSink || !pdwAdvf || !pdwAspects)
  90. hr = E_INVALIDARG;
  91. else
  92. {
  93. *ppAdvSink = _pViewSink;
  94. _pViewSink->AddRef();
  95. if (pdwAspects != NULL)
  96. *pdwAspects = _dwViewAspects;
  97. if (pdwAdvf != NULL)
  98. *pdwAdvf = _dwViewAdvf;
  99. }
  100. return hr;
  101. }
  102. HRESULT CPackage::GetExtent(DWORD dwAspect, LONG lindex,
  103. DVTARGETDEVICE *ptd, LPSIZEL pszl)
  104. {
  105. HRESULT hr = S_OK;
  106. DebugMsg(DM_TRACE,"pack vo - GetExtent() called.");
  107. if (pszl == NULL)
  108. hr = E_INVALIDARG;
  109. if (!_lpic)
  110. hr = OLE_E_BLANK;
  111. if(SUCCEEDED(hr))
  112. {
  113. pszl->cx = _lpic->rc.right;
  114. pszl->cy = _lpic->rc.bottom;
  115. pszl->cx = MulDiv(pszl->cx,HIMETRIC_PER_INCH,DEF_LOGPIXELSX);
  116. pszl->cy = MulDiv(pszl->cy,HIMETRIC_PER_INCH,DEF_LOGPIXELSY);
  117. }
  118. return hr;
  119. }