home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-14 | 2.9 KB | 127 lines | [TEXT/CWIE] |
- // =================================================================================
- //
- // CTextEditBSC.cpp ©1996 Microsoft Corporation All rights reserved.
- //
- // =================================================================================
-
- #include "ocheaders.h"
- #include "CTextEditBSC.h"
- #include "CTextEditControl.h"
- #include "urlmonsupport.h"
-
- #pragma mark === CTextEditBSC::Construction & Destruction ===
-
- //
- // CTextEditBSC::CTextEditBSC
- //
- // initialize our members
- //
-
- CTextEditBSC::CTextEditBSC(void)
- : CBaseBindStatusCallback()
- {
- mData = NULL;
- mBusy = false;
- }
-
-
- #pragma mark === CTextEditBSC::IBindStatusCallback ===
-
- //
- // CTextEditBSC::IBindStatusCallback::OnStopBinding
- //
- // wrap up the stream
- //
-
- STDMETHODIMP
- CTextEditBSC::OnStopBinding(ErrorCode Result, const Char8* Error)
- {
- CBaseBindStatusCallback::OnStopBinding(Result, Error);
- mBusy = false;
-
- return S_OK;
- }
-
-
- //
- // CTextEditBSC::IBindStatusCallback::OnDataAvailable
- //
- // data has become available - put it into our buffer
- //
-
- STDMETHODIMP
- CTextEditBSC::OnDataAvailable(Uint32 BSCF, Uint32 Size, FORMATETC* FormatEtc, STGMEDIUM* StgMedium)
- {
- OSErr Err = noErr;
-
- CBaseBindStatusCallback::OnDataAvailable(BSCF, Size, FormatEtc, StgMedium);
-
- if (StgMedium->pUnkForRelease != NULL)
- StgMedium->pUnkForRelease->Release();
-
- return S_OK;
- }
-
-
- #pragma mark === CTextEditBSC::Public methods ===
-
-
- //=--------------------------------------------------------------------------=
- // CBaseBindStatusCallback::OpenStream
- //=--------------------------------------------------------------------------=
- //
- ErrorCode
- CTextEditBSC::OpenPostStream(IContainerSite* inContainerSiteP, LPOLESTR URLString,
- Handle PostData)
- {
- ErrorCode Result = E_FAIL;
- LPBINDHOST BindSiteP;
- LPMONIKER URLMoniker = NULL;
- LPBINDCTX BindContext = NULL;
-
- if(!mBusy)
- {
- inContainerSiteP->QueryInterface(IID_IBindHost, (LPVOID *) &BindSiteP);
-
- if (BindSiteP)
- {
- Result = BindSiteP->CreateMoniker((LPOLESTR)URLString, NULL, &URLMoniker, 0);
- if(SUCCEEDED(Result) && URLMoniker)
- {
- void* Dummy;
-
- mData = PostData;
- mBusy = true;
- Result = BindSiteP->MonikerBindToStorage(URLMoniker, NULL,
- (IBindStatusCallback*)this, IID_IStream, &Dummy);
- if(Result == E_PENDING)
- Result = S_OK;
- URLMoniker->Release();
- }
- }
- }
- if(Result != S_OK)
- DisposeHandle(PostData);
-
- return Result;
- }
-
- //=--------------------------------------------------------------------------=
- // CBaseBindStatusCallback::IBindStatusCallback::GetBindInfo
- //=--------------------------------------------------------------------------=
- //
- STDMETHODIMP
- CTextEditBSC::GetBindInfo(Uint32* BINDF, BINDINFO *BindInfo)
- {
- *BINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
- BindInfo->dwBindVerb = BINDVERB_POST;
- BindInfo->cbstgmedData = GetHandleSize(mData);
- BindInfo->stgmedData.tymed = TYMED_HGLOBAL;
- BindInfo->stgmedData.hGlobal = mData;
- AddRef();
- BindInfo->stgmedData.pUnkForRelease = NULL;
-
- return S_OK;
- }
-
-