
/*
*********************************************************************
*
*	The Essence of OLE
*
*	Source code sample
*
*	Copyright (c) 1996, Rolling Thunder Computing, Ipswich MA
*
*	e-mail: essence@rollthunder.com
*	CompuServe: 73540,3430
*	Web: http://www.rollthunder.com
*
*	File Name: ITEMCONT.CPP
*
*	Purpose: Implementation of IOleItemContainer interface 
*
*********************************************************************
*/

#include <windows.h>
#include "cfiletextdata.h"


STDMETHODIMP CFileTextData::GetObject(LPOLESTR pWideItemName, 
	DWORD dwSpeed, LPBINDCTX pbc, REFIID riid, LPVOID *ppv)
{

	HRESULT hr ;
	char ItemName [256] ;

 /*
 Convert item name from wide to the ansi the we use
 */

	WideCharToMultiByte (CP_ACP, 0, pWideItemName, -1,
		ItemName, sizeof(ItemName), NULL, NULL) ;

/*
Parse first and last character out of item name
*/

	char *pColon  = strchr (ItemName, ':') ;
	*(pColon) = 0x00 ;

	int first = atoi (ItemName) ;
	int last = atoi (pColon+1) ;

/*
Instantiate new CFileTextData object, using the overloaded
constuctor that allows us to specify a data pointer and an
extent.
*/

	CFileTextData *pNewTextData = new CFileTextData (m_cp+first, last-first) ;

    hr = pNewTextData->QueryInterface(riid, ppv);
    pNewTextData->Release();

	return hr ;
}


STDMETHODIMP CFileTextData::LockContainer(BOOL fLock)
{
    if (fLock)
    {
		AddRef();
	}
    else
	{
        Release();
	}

    return NOERROR;
}


STDMETHODIMP CFileTextData::GetObjectStorage(LPOLESTR pszItem,
	LPBINDCTX pbc, REFIID riid, LPVOID *ppv)
{

	MessageBox (NULL, "GetObjectStorage", "", 0) ;
    return NOERROR;
}


STDMETHODIMP CFileTextData::IsRunning(LPOLESTR pszItem)
{
	MessageBox (NULL, "IsRunning", "", 0) ;
    return NOERROR ;
}

STDMETHODIMP CFileTextData::ParseDisplayName(LPBC pbc
    , LPOLESTR pszName, ULONG *pchEaten, LPMONIKER *ppmk)
{
	MessageBox (NULL, "ParseDisplayName", "", 0) ;
	return NOERROR ;
}


STDMETHODIMP CFileTextData::EnumObjects(DWORD dwFlags, LPENUMUNKNOWN *ppEnum)
{
	MessageBox (NULL, "EnumObjects", "", 0) ;
    *ppEnum = NULL;
    return E_NOTIMPL ;
}



