我作的是一个 ole 文档程序, 在 ole object 定点激活时候, 怎样才能去掉 server 加上的 toolbar, 我使用 mfc 作的, 谢谢!!!

解决方案 »

  1.   

    STDMETHODIMP COleInPlaceSite::GetWindowContext (LPOLEINPLACEFRAME FAR* lplpFrame,
                                                               LPOLEINPLACEUIWINDOW FAR* lplpDoc,
                                                               LPRECT lprcPosRect,
                                                               LPRECT lprcClipRect,
                                                               LPOLEINPLACEFRAMEINFO lpFrameInfo)
    {
            RECT rect;
            CStabilize stabilize(m_pSite);        OutputDebugString("In IOIPS::GetWindowContext\r\n");        // the frame is associated with the application object.
            // need to AddRef() it...
            m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame.AddRef();
            *lplpFrame = NULL;
            *lplpDoc = NULL;  // must be NULL, cause we're SDI.        // get the size of the object in pixels
            m_pSite->GetObjRect(&rect);        // Copy this to the passed buffer
            CopyRect(lprcPosRect, &rect);        // fill the clipping region
            GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
            CopyRect(lprcClipRect, &rect);        // fill the FRAMEINFO
            lpFrameInfo->fMDIApp = FALSE;
            lpFrameInfo->hwndFrame = m_pSite->m_lpDoc->m_lpApp->m_hAppWnd;
            lpFrameInfo->haccel = NULL;
            lpFrameInfo->cAccelEntries = 0;        return S_OK;
    }
      

  2.   

    ole doc的命令执行可以参考IOleCommandTarget接口的OLECMDID枚举,如OLECMDID_HIDETOOLBARS
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/ae1592b6-2afd-4379-a18e-d46b226bc9e2.asp
      

  3.   

    关键是*lplpFrame = NULL; 说明没有Frame窗口,菜单,工具兰,状态兰自然就没有了!
      

  4.   

    to :goodboyws(深夜不眠者(VCMVP)) 我用的是mfc写的,从coleclientitem 继承来, 
    BEGIN_INTERFACE_PART(OleIPSite, IOleInPlaceSite)
    INIT_INTERFACE_PART(COleClientItem, OleIPSite)
    STDMETHOD(GetWindow)(HWND*);
    STDMETHOD(ContextSensitiveHelp)(BOOL);
    STDMETHOD(CanInPlaceActivate)();
    STDMETHOD(OnInPlaceActivate)();
    STDMETHOD(OnUIActivate)();
    STDMETHOD(GetWindowContext)(LPOLEINPLACEFRAME*,
    LPOLEINPLACEUIWINDOW*, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO);
    STDMETHOD(Scroll)(SIZE);
    STDMETHOD(OnUIDeactivate)(BOOL);
    STDMETHOD(OnInPlaceDeactivate)();
    STDMETHOD(DiscardUndoState)();
    STDMETHOD(DeactivateAndUndo)();
    STDMETHOD(OnPosRectChange)(LPCRECT);
    END_INTERFACE_PART(OleIPSite) ,怎么才能重写这个接口呢?
      

  5.   

    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(COleDocDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(COleDocView));
    pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
    pDocTemplate->SetServerInfo(
    IDR_SRVR_EMBEDDED, IDR_SRVR_INPLACE,
    RUNTIME_CLASS(CInPlaceFrame));
    AddDocTemplate(pDocTemplate);SetServerInfo
    Parameters
    nIDOleEmbedding 
    The ID of the resources used when an embedded object is opened in a separate window. 
    nIDOleInPlaceServer 
    The ID of the resources used when an embedded object is activated in-place. 
    pOleFrameClass 
    Pointer to a CRuntimeClass structure containing class information for the frame window object created when in-place activation occurs. 
    pOleViewClass 
    Pointer to a CRuntimeClass structure containing class information for the view object created when in-place activation occurs. 这下你不明白我打你
      

  6.   

    to : onestation(新手) midnightsky() 我看了一下 mfc 的源码, 不对呀, 我要的是定点激活, 按两位说得如果 lplpFrame 空的话, 那没server就没有获得一个 定点激活的frame, 就会自己弹出一个窗口 (oleverb_open)形式的,STDMETHODIMP COleClientItem::XOleIPSite::GetWindowContext(
    LPOLEINPLACEFRAME* lplpFrame,
    LPOLEINPLACEUIWINDOW* lplpDoc,
    LPRECT lpPosRect, LPRECT lpClipRect,
    LPOLEINPLACEFRAMEINFO lpFrameInfo)
    {
    METHOD_PROLOGUE_EX(COleClientItem, OleIPSite)
    ASSERT_VALID(pThis);
    *lplpFrame = NULL;  // init these in-case of mem-alloc failure
    *lplpDoc = NULL; CFrameWnd* pMainFrame = NULL;
    CFrameWnd* pDocFrame = NULL; SCODE sc = E_UNEXPECTED;
    TRY
    {
    // get position of the item relative to activation view
    CRect rect;
    pThis->OnGetItemPosition(rect);
    ::CopyRect(lpPosRect, &rect);
    pThis->OnGetClipRect(rect);
    ::CopyRect(lpClipRect, &rect); // get the window context information
    if (pThis->OnGetWindowContext(&pMainFrame, &pDocFrame, lpFrameInfo))
    {
    // hook IOleInPlaceFrame interface to pMainFrame
    if (pThis->m_pInPlaceFrame == NULL)
    pThis->m_pInPlaceFrame = new COleFrameHook(pMainFrame, pThis);
    pThis->m_pInPlaceFrame->InternalAddRef();
    *lplpFrame = (LPOLEINPLACEFRAME)pThis->m_pInPlaceFrame->
    GetInterface(&IID_IOleInPlaceFrame); // save accel table for IOleInPlaceFrame::TranslateAccelerators
    pThis->m_pInPlaceFrame->m_hAccelTable = lpFrameInfo->haccel; // hook IOleInPlaceUIWindow to pDocFrame
    if (pDocFrame != NULL)
    {
    if (pThis->m_pInPlaceDoc == NULL)
    pThis->m_pInPlaceDoc = new COleFrameHook(pDocFrame, pThis);
    pThis->m_pInPlaceDoc->InternalAddRef();
    *lplpDoc = (LPOLEINPLACEUIWINDOW)pThis->m_pInPlaceDoc->
    GetInterface(&IID_IOleInPlaceUIWindow);
    }
    sc = S_OK;
    }
    }
    CATCH_ALL(e)
    {
    // cleanup memory that may be partially allocated
    delete *lplpFrame;
    ASSERT(*lplpDoc == NULL);
    DELETE_EXCEPTION(e);
    }
    END_CATCH_ALL return sc;
    }当 ongetwindowcontext 返回 null 的时候, 新打开一个窗口, 没有定点激活, 
      

  7.   

    to: wlwlxj(wlwlxj)  
    哈哈, 我看要打的不是我呀, 
    你发的代码应该是 ole object activate 时候, server 端加的资源是什么,我现在想要的是, 从 client 端来控制, 让 server 端的 toolbar 不显示, 有办法没????
      

  8.   

    多谢各位, 解决了, 只要重载一下 cframewnd 里的 negotiatetoolspace 就可以了,