示例#1
0
BOOL CRectItem::UpdateExtent()
{
	// get size in pixels
	CSize size;
	if (!GetCachedExtent(&size))
		return FALSE;       // blank
	Invalidate();   // invalidate the old size/position
	CSize sizeBase = GetBaseSize();
	if (size == sizeBase) // no change
		return FALSE;
	// if new object (i.e. m_extent is empty) setup position
	if (sizeBase == CSize(0,0))
	{
		// convert to document coords
		CSize sizeNew(MulDiv(size.cx, 10, 254), - MulDiv(size.cy, 10, 254));
		SetSize(sizeNew);
	}
	else
	{
		if (!IsInPlaceActive() && size != sizeBase)
		{
			// data changed and not inplace, so scale up rect as well
			CSize sizeCur = GetSize();
			sizeCur.cx = MulDiv(sizeCur.cx, size.cx, sizeBase.cx);
			sizeCur.cy = - MulDiv(-sizeCur.cy, size.cy, sizeBase.cy);
			SetSize(sizeCur);
		}
	}
	SetBaseSize(size);
	Invalidate();   // as well as the new size/position
	return TRUE;
}
示例#2
0
BOOL COleClientItem::ReactivateAndUndo()
{
	ASSERT_VALID(this);
	ASSERT(m_lpObject != NULL);
	ASSERT(IsInPlaceActive());

	// get IOleInPlaceObject interface
	LPOLEINPLACEOBJECT lpInPlaceObject =
		QUERYINTERFACE(m_lpObject, IOleInPlaceObject);
	if (lpInPlaceObject == NULL)
	{
		Close();    // handle rare failure cases by calling Close
		return FALSE;
	}

	// call IOleInPlaceObject::ReactivateAndUndo
	m_scLast = lpInPlaceObject->ReactivateAndUndo();
	lpInPlaceObject->Release();
	if (FAILED(m_scLast))
	{
		Close();    // handle rare failure cases by calling Close
		return FALSE;
	}
	return TRUE;
}
示例#3
0
void CContainerItem::UpdateFromServerExtent()
{
	CSize size;
	if (GetCachedExtent(&size))
	{
		// OLE returns the extent in HIMETRIC units -- we need pixels
		CClientDC dc(NULL);
		dc.HIMETRICtoDP(&size);

		// Only invalidate if it has actually changed, and also
		// only if it is not in-place active.  When in-place active, the
		// container item size should sync with the "window size" of the
		// object.  Only when not in-place active should the container 
		// item size should sync with the natural size of the object.

		if ((size != m_rect.Size()) && !IsInPlaceActive())
		{
			// invalidate old, update, invalidate new
			InvalidateItem();
			m_rect.bottom = m_rect.top + size.cy;
			m_rect.right = m_rect.left + size.cx;
			InvalidateItem();

			// mark document as modified
			GetDocument()->SetModifiedFlag();
		}
	}
}
示例#4
0
void COleClientItem::Deactivate()
{
	ASSERT_VALID(this);
	ASSERT(m_lpObject != NULL);
	ASSERT(IsInPlaceActive());

	// get IOleInPlaceObject interface
	LPOLEINPLACEOBJECT lpInPlaceObject =
		QUERYINTERFACE(m_lpObject, IOleInPlaceObject);
	if (lpInPlaceObject == NULL)
	{
		Close();    // handle rare failure cases by calling Close
		return;
	}

	// call IOleInPlaceObject::InPlaceDeactivate
	m_scLast = lpInPlaceObject->InPlaceDeactivate();
	lpInPlaceObject->Release();
	if (FAILED(m_scLast))
	{
		Close();    // handle rare failure cases by calling Close
		return;
	}
	m_nItemState = loadedState; // just in case server has crashed
}
示例#5
0
BOOL CDrawItem::UpdateExtent()
{
	CSize size;
	if (!GetExtent(&size) || size == m_pDrawObj->m_extent)
		return FALSE;       // blank

	// if new object (i.e. m_extent is empty) setup position
	if (m_pDrawObj->m_extent == CSize(0, 0))
	{
		m_pDrawObj->m_position.right =
			m_pDrawObj->m_position.left + MulDiv(size.cx, 10, 254);
		m_pDrawObj->m_position.bottom =
			m_pDrawObj->m_position.top - MulDiv(size.cy, 10, 254);
	}
	// else data changed so scale up rect as well
	else if (!IsInPlaceActive() && size != m_pDrawObj->m_extent)
	{
		m_pDrawObj->m_position.right = m_pDrawObj->m_position.left +
			MulDiv(m_pDrawObj->m_position.Width(), size.cx, m_pDrawObj->m_extent.cx);
		m_pDrawObj->m_position.bottom = m_pDrawObj->m_position.top +
			MulDiv(m_pDrawObj->m_position.Height(), size.cy, m_pDrawObj->m_extent.cy);
	}

	m_pDrawObj->m_extent = size;
	m_pDrawObj->Invalidate();   // redraw to the new size/position
	return TRUE;
}
示例#6
0
//////////////////////////////////////////////////////////////////////////////////
//功 能:
//////////////////////////////////////////////////////////////////////////////////
BOOL CCtrlItem::UpdateExtent()
{
	if (m_lpViewObject == NULL)
		return TRUE;

	CSize size;

	//下行调用m_lpViewObject,此时m_lpViewObject对部分控件可能为空
	if (GetCachedExtent(&size)) 
	{
		// OLE returns the extent in HIMETRIC units -- we need pixels.
		CClientDC dc(NULL);
		dc.HIMETRICtoDP(&size);

		// Only invalidate if it has actually changed and also only if it is not
		// in-place active.
		CSize szTmp;
		szTmp.cx = int(m_pCtrlObj->m_position.Size().cx);
		szTmp.cy = int(m_pCtrlObj->m_position.Size().cy);
		if ((size != szTmp) && !IsInPlaceActive())
		{
			// Invalidate old, update, invalidate new.
			m_pCtrlObj->Invalidate();
			m_pCtrlObj->m_position.bottom = m_pCtrlObj->m_position.top + size.cy;
			m_pCtrlObj->m_position.right = m_pCtrlObj->m_position.left + size.cx;
			m_pCtrlObj->Invalidate();

			// mark document as modified.
			GetDocument()->SetModifiedFlag();
		}
	}

	return TRUE;
}
示例#7
0
//////////////////////////////////////////////////////////////////////////////////////////
//功 能:获取外围裁剪矩形
//////////////////////////////////////////////////////////////////////////////////////////
void CCtrlItem::OnGetClipRect(CRect& rectClip)
{
	ASSERT_VALID(this);

   	CLayoutView* pView = GetActiveView();
	CRect rectTemp = m_pCtrlObj->m_position.GetRECT();
	//在位激活并且为窗口模式时变更坐标
	if (IsInPlaceActive() && !m_bWindowless)
		pView->DocToClient(rectTemp);

	rectClip = rectTemp;
}
示例#8
0
void CRectItem::Move(CRect &rc)
{
	// invalidate old rect
	Invalidate();
	// invalidate new
	SetRect(rc);
	Invalidate();

	// update item rect when in-place active
	if (IsInPlaceActive())
		SetItemRects();
}
示例#9
0
void COleClientItem::Activate(LONG nVerb, CView* pView, LPMSG lpMsg)
{
    ASSERT_VALID(this);
    ASSERT(m_lpObject != NULL);
    if (pView != NULL)
        ASSERT_VALID(pView);
    if (lpMsg != NULL)
        ASSERT(AfxIsValidAddress(lpMsg, sizeof(MSG), FALSE));

    // store the container HWND for in place activation then do the verb
    if (m_pView == NULL)
        m_pView = pView;

    _AFX_OLE_STATE* pOleState = _afxOleState;
    CView* pViewSave = pOleState->m_pActivateView;
    pOleState->m_pActivateView = NULL;

    // get item rectangle for in-place players
    //  (that may not support in-place activation)
    LPCRECT lpPosRect = NULL;
    CRect rectPos;
    if (pView != NULL)
    {
        ASSERT_VALID(pView);
        rectPos.SetRectEmpty();
        OnGetItemPosition(rectPos);
        if (!rectPos.IsRectEmpty())
        {
            lpPosRect = &rectPos;
            pOleState->m_pActivateView = pView;
        }
    }

    // prepare DoVerb parameters and call into the server
    LPOLECLIENTSITE lpClientSite = GetClientSite();
    HWND hWnd = pView->GetSafeHwnd();
    SCODE sc = m_lpObject->DoVerb(nVerb, lpMsg, lpClientSite, -1,
                                  hWnd, lpPosRect);

    pOleState->m_pActivateView = pViewSave;

    // clear out m_pView in case in-place activation only partially worked
    if (!IsInPlaceActive())
        m_pView = NULL;

    // update available status based on the results of DoVerb
    //  (this is used in the links dialog).
    m_bLinkUnavail = (BYTE)FAILED(sc);

    CheckGeneral(sc);
}
示例#10
0
void CCtrlItem::OnGetItemPosition(CRect& rPosition)
{
	ASSERT_VALID(this);

	// update to extent of item if m_position is not initialized
	if (m_pCtrlObj->m_position.IsRectEmpty())
		UpdateExtent();

	// copy m_position, which is in document coordinates
	CLayoutView* pView = GetActiveView();
	ASSERT_VALID(pView);
	rPosition = m_pCtrlObj->m_position.GetRECT();
	//在位激活并且为窗口模式时变更坐标
	if (IsInPlaceActive() && !m_bWindowless)
		pView->DocToClient(rPosition);
}
示例#11
0
void CNetscapeCntrItem::OnDeactivateUI(BOOL bUndoable)
{

	COleClientItem::OnDeactivateUI(bUndoable);
	// Close an in-place active item whenever it removes the user
	//  interface.  The action here should match as closely as possible
	//  to the handling of the escape key in the view.
	if( IsInPlaceActive() == TRUE)   {
		TRY	{
	        Deactivate();

		}
		CATCH(CException, e)	{
			//	Something went wrong in OLE (other app down).
			//	No complicated handling here, just keep running.
		}
		END_CATCH
	}
示例#12
0
BOOL COleClientItem::SetItemRects(LPCRECT lpPosRect, LPCRECT lpClipRect)
{
	ASSERT_VALID(this);
	ASSERT(m_lpObject != NULL);
	ASSERT(IsInPlaceActive());
	ASSERT(lpPosRect == NULL ||
		AfxIsValidAddress(lpPosRect, sizeof(RECT), FALSE));
	ASSERT(lpClipRect == NULL ||
		AfxIsValidAddress(lpClipRect, sizeof(RECT), FALSE));

	// get IOleInPlaceObject interface
	LPOLEINPLACEOBJECT lpInPlaceObject =
		QUERYINTERFACE(m_lpObject, IOleInPlaceObject);
	if (lpInPlaceObject == NULL)
		return FALSE;   // perhaps server crashed?

	// use OnGetPosRect if rectangle not specified
	CRect rectPos;
	if (lpPosRect == NULL)
	{
		ASSERT(lpClipRect == NULL);
		OnGetItemPosition(rectPos);
		lpPosRect = &rectPos;
	}

	// use OnGetClipRect if clipping rectangle not specified
	CRect rectClip;
	if (lpClipRect == NULL)
	{
		OnGetClipRect(rectClip);
		lpClipRect = &rectClip;
	}
	ASSERT(lpPosRect != NULL);
	ASSERT(lpClipRect != NULL);

	// notify the server of the new item rectangles
	m_scLast = lpInPlaceObject->SetObjectRects(lpPosRect, lpClipRect);
	lpInPlaceObject->Release();

	// remember position rectangle as cached position
	return !FAILED(m_scLast);
}
示例#13
0
BOOL COleClientItem::OnChangeItemPosition(const CRect& rectPos)
{
	if (!IsInPlaceActive())
		return FALSE;

	ASSERT_VALID(this);
	ASSERT(AfxIsValidAddress(&rectPos, sizeof(CRect), FALSE));
	ASSERT_VALID(m_pView);

	// determine the visible rect based on intersection between client rect
	CRect clipRect;
	OnGetClipRect(clipRect);
	CRect visRect;
	visRect.IntersectRect(clipRect, rectPos);

	// advise the server of the new visible rectangle
	if (!visRect.IsRectEmpty())
		return SetItemRects(&rectPos, &clipRect);

	return FALSE;
}
示例#14
0
//////////////////////////////////////////////////////////////////////////
//功 能:绘制项目
//////////////////////////////////////////////////////////////////////////
BOOL CCtrlItem::Draw(CDC* pDC, LPCRECT prectBounds,
	DVASPECT nDrawAspect)
{
	RECTL rclBounds;
	RECTL* prclBounds;
	CRect rectClip;
	CSize size;

	if (m_lpObject == NULL || m_lpViewObject == NULL)
	{
		return FALSE;
	}

	//项目为窗体控件,返回
	if (IsInPlaceActive() && !m_bWindowless)
    {
 		return FALSE;
    }

	// convert RECT lpBounds to RECTL rclBounds
	rclBounds.left = prectBounds->left;
	rclBounds.top = prectBounds->top;
	rclBounds.right = prectBounds->right;
	rclBounds.bottom = prectBounds->bottom;

	if (m_bWindowless)
	{
		prclBounds = NULL;
	}
	else
	{
		prclBounds = &rclBounds;
	}

	m_lpViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, pDC->m_hDC,
		prclBounds, NULL, NULL, 0);

	return TRUE;
}
示例#15
0
BOOL CCtrlItem::DrawBackToFront(CDC* pDC, LPCRECT prectBounds)
{
	RECTL rclBounds;
	RECTL* prclBounds;
	DWORD dwViewStatus;

	if (m_lpObject == NULL || m_lpViewObject == NULL)
	{
		return FALSE;
	}

	if (IsInvisibleAtRuntime())
	{
		// We are invisible.
		return FALSE;
	}

    if (IsInPlaceActive() && !m_bWindowless)
    {
 		return FALSE;
    }

	// convert RECT lpBounds to RECTL rclBounds
	rclBounds.left = prectBounds->left;
	rclBounds.top = prectBounds->top;
	rclBounds.right = prectBounds->right;
	rclBounds.bottom = prectBounds->bottom;

	if (m_bWindowless)
	{
		prclBounds = NULL;
	}
	else
	{
		prclBounds = &rclBounds;
	}

	if (m_pViewObjectEx != NULL)
	{
		m_pViewObjectEx->GetViewStatus(&dwViewStatus);
		ASSERT(dwViewStatus == m_dwViewStatus);
	}
	else
	{
		ASSERT(m_dwViewStatus == 0);
	}

	if ((m_dwAspectPass2 == DVASPECT_TRANSPARENT)&&(m_dwViewStatus&
		VIEWSTATUS_DVASPECTTRANSPARENT))
	{
		m_lpViewObject->Draw( DVASPECT_TRANSPARENT, -1, NULL, NULL, NULL,
			pDC->m_hDC, prclBounds, NULL, NULL, 0 );
	}
	else if (m_dwAspectPass2 == DVASPECT_CONTENT)
	{
		m_lpViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, pDC->m_hDC,
			prclBounds, NULL, NULL, 0);
	}

	return TRUE;
}
示例#16
0
BOOL CCtrlItem::DrawFrontToBack(CDC* pDC, LPCRECT prectBounds)
{
	HRESULT hResult;
	RECTL rclBounds;
	RECTL* prclBounds;
	DWORD dwViewStatus;
	RECTL rclClip;
	CRect rectClip;
	CSize size;

	if ((m_lpObject == NULL) || (m_lpViewObject == NULL))
	{
		return FALSE;
	}

	//如果是在位激活且窗口模式退出
	if (IsInPlaceActive() && !m_bWindowless)
	{
		return FALSE;
	}

	//不支持两遍绘制
	if (m_pViewObjectEx == NULL)
	{
		// The control doesn't understand two-pass drawing, so just draw it on
		// pass 2.
		return FALSE ;
	}

	//不可见退出
	if(IsInvisibleAtRuntime() )
	{
		// We are invisible.
		return FALSE;
	}

	// convert RECT lpBounds to RECTL rclBounds
	rclBounds.left = prectBounds->left;
	rclBounds.top = prectBounds->top;
	rclBounds.right = prectBounds->right;
	rclBounds.bottom = prectBounds->bottom;

	if (m_bWindowless)
	{
		prclBounds = NULL;
	}
	else
	{
		prclBounds = &rclBounds;
	}

	// Assume that we won't be able to draw the first pass.
	m_dwAspectPass2 = DVASPECT_CONTENT;

	m_pViewObjectEx->GetViewStatus( &dwViewStatus );
	m_dwViewStatus = dwViewStatus;
	ASSERT( m_dwViewStatus == dwViewStatus );
	//不支持不透明性退出
	if (!(m_dwViewStatus&VIEWSTATUS_DVASPECTOPAQUE))
	{
		return FALSE;
	}

	//返回不透明区域
	hResult = m_pViewObjectEx->GetRect(DVASPECT_OPAQUE, &rclClip);
	if (FAILED(hResult))
	{
		return FALSE;
	}

	hResult = m_lpViewObject->Draw(DVASPECT_OPAQUE, -1, NULL, NULL, NULL,
		pDC->m_hDC, prclBounds, NULL, NULL, 0);
	if (SUCCEEDED(hResult))
	{
		// Just draw the transparent part in pass 2.
		m_dwAspectPass2 = DVASPECT_TRANSPARENT;
	}

	size = CSize(rclClip.left, rclClip.top);
	pDC->HIMETRICtoDP(&size);
	rectClip.left = int(m_pCtrlObj->m_position.left+size.cx);
	rectClip.top = int(m_pCtrlObj->m_position.top+size.cy);
	size = CSize(rclClip.right, rclClip.bottom);
	pDC->HIMETRICtoDP(&size);
	rectClip.right = int(m_pCtrlObj->m_position.left+size.cx);
	rectClip.bottom = int(m_pCtrlObj->m_position.top+size.cy);
	//将此区域切掉
	pDC->ExcludeClipRect(&rectClip);

	return TRUE;
}
示例#17
0
void CPadDoc::OnCancelInplace()
{
	if (IsInPlaceActive())
		OnDeactivateUI(FALSE);
}