STDMETHODIMP tOleClientSite::RequestNewObjectLayout(void) { RECT rc, rcT; SIZEL szl; HRESULT hr; /* * This function is called by a control that is not in-place * active or UI active and therefore doesn't have our * IOleInPlaceSite interface in which to call OnPosRectChange. * Therefore we do pretty much the same thing we do in that * function although we ask the control for the size it wants. */ if (!handler->m_pIViewObject2) return E_FAIL; //Get the size from the control hr=handler->m_pIViewObject2->GetExtent(handler->m_fe.dwAspect, -1, NULL, &szl); if (FAILED(hr)) return hr; //Add these extents to the existing tenant position. SetRect(&rcT, 0, 0, szl.cx*10, -szl.cy*10); RectConvertMappings(&rcT, NULL, TRUE); rc=handler->m_rcPos; rc.right=rc.left+rcT.right; rc.bottom=rc.top+rcT.bottom; handler->UpdateInPlaceObjectRects(&rc, FALSE); return NOERROR; }
void tOleHandler::RectGet(LPRECTL prcl, BOOL fDevice) { if (!fDevice) *prcl=m_rcl; else { RECT rc; RECTFROMRECTL(rc, m_rcl); RectConvertMappings(&rc, NULL, TRUE); RECTLFROMRECT(*prcl, rc); } return; }
void tOleHandler::RectSet(LPRECTL prcl, BOOL fDevice, BOOL fInformObj) { SIZEL szl; LONG cx, cy; /* * Prevent reentrant calls that may come from calling * UpdateInPlaceObjectRects here and elsewhere. */ if (m_fInRectSet) return; m_fInRectSet=TRUE; cx=m_rcl.right-m_rcl.left; cy=m_rcl.bottom-m_rcl.top; if (!fDevice) m_rcl=*prcl; else { RECT rc; RECTFROMRECTL(rc, *prcl); RectConvertMappings(&rc, NULL, FALSE); RECTLFROMRECT(m_rcl, rc); } /* * Tell ourselves that the size changed, if it did. SizeSet * will call IOleObject::SetExtent for us. */ if ((m_rcl.right-m_rcl.left)!=cx || (m_rcl.bottom-m_rcl.top)!=cy) { SETSIZEL(szl, m_rcl.right-m_rcl.left, m_rcl.bottom-m_rcl.top); SizeSet(&szl, FALSE, fInformObj); } //Tell an in-place active object it moved too UpdateInPlaceObjectRects(NULL, TRUE); m_fInRectSet=FALSE; return; }
BOOL tOleHandler::Activate(LONG iVerb, LPMSG pMSG) { RECT rc, rcH; SIZEL szl; //Can't activate statics. /* if (TENANTTYPE_STATIC==m_tType || NULL==m_pIOleObject) { MessageBeep(0); return FALSE; }*/ RECTFROMRECTL(rc, m_rcl); RectConvertMappings(&rc, NULL, TRUE); XformRectInPixelsToHimetric(NULL, &rc, &rcH); //Get the server running first, then do a SetExtent, then show it OleRun(m_pIOleObject); if (m_fSetExtent) { SETSIZEL(szl, rcH.right-rcH.left, rcH.top-rcH.bottom); m_pIOleObject->SetExtent(m_fe.dwAspect, &szl); m_fSetExtent=FALSE; } //CHAPTER24MOD /* * If we have a pending deactivation, but we're activating * again, clear the pending flag. */ if (OLEIVERB_UIACTIVATE==iVerb || OLEIVERB_INPLACEACTIVATE==iVerb) m_fPendingDeactivate=FALSE; //End CHAPTER24MOD m_pIOleObject->DoVerb(iVerb, pMSG, m_pImpIOleClientSite, 0 , m_hWnd, &rcH); //If object changes, IAdviseSink::OnViewChange will see it. return FALSE; }
void tOleHandler::SizeGet(LPSIZEL pszl, BOOL fDevice) { if (!fDevice) { pszl->cx=m_rcl.right-m_rcl.left; pszl->cy=m_rcl.bottom-m_rcl.top; } else { RECT rc; SetRect(&rc, (int)(m_rcl.right-m_rcl.left) , (int)(m_rcl.bottom-m_rcl.top), 0, 0); RectConvertMappings(&rc, NULL, TRUE); pszl->cx=(long)rc.left; pszl->cy=(long)rc.top; } return; }
void tOleHandler::SizeSet(LPSIZEL pszl, BOOL fDevice, BOOL fInformObj) { SIZEL szl; if (!fDevice) { szl=*pszl; m_rcl.right =pszl->cx+m_rcl.left; m_rcl.bottom=pszl->cy+m_rcl.top; } else { RECT rc; SetRect(&rc, (int)pszl->cx, (int)pszl->cy, 0, 0); RectConvertMappings(&rc, NULL, FALSE); m_rcl.right =(long)rc.left+m_rcl.left; m_rcl.bottom=(long)rc.top+m_rcl.top; SETSIZEL(szl, (long)rc.left, (long)rc.top); } //Tell OLE that this object was resized. if (NULL!=m_pIOleObject && fInformObj) { HRESULT hr; BOOL fRun=FALSE; //Convert our LOMETRIC into HIMETRIC by *=10 szl.cx*=10; szl.cy*=-10; //Our size is stored negative. /* * If the MiscStatus bit of OLEMISC_RECOMPOSEONRESIZE * is set, then we need to run the object before calling * SetExtent to make sure it has a real chance to * re-render the object. We have to update and close * the object as well after this happens. */ if (OLEMISC_RECOMPOSEONRESIZE & m_grfMisc) { if (!OleIsRunning(m_pIOleObject)) { OleRun(m_pIOleObject); fRun=TRUE; } } hr=m_pIOleObject->SetExtent(m_fe.dwAspect, &szl); /* * If the object is not running and it does not have * RECOMPOSEONRESIZE, then SetExtent fails. Make * sure that we call SetExtent again (by just calling * SizeSet here again) when we next run the object. */ if (SUCCEEDED(hr)) { m_fSetExtent=FALSE; if (fRun) { m_pIOleObject->Update(); m_pIOleObject->Close(OLECLOSE_SAVEIFDIRTY); } } else { if (OLE_E_NOTRUNNING==GetScode(hr)) m_fSetExtent=TRUE; } } return; }