Click here to Skip to main content
15,901,205 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multilingual Support Pin
Marc Soleda7-Sep-05 21:12
Marc Soleda7-Sep-05 21:12 
GeneralC++ Class design tool Pin
TssPrasad7-Sep-05 18:08
sussTssPrasad7-Sep-05 18:08 
GeneralRe: C++ Class design tool Pin
Marc Soleda7-Sep-05 22:16
Marc Soleda7-Sep-05 22:16 
QuestionHow does CListCtrl notify its parent window when a cell content has changed? Pin
followait7-Sep-05 17:39
followait7-Sep-05 17:39 
AnswerRe: How does CListCtrl notify its parent window when a cell content has changed? Pin
ThatsAlok7-Sep-05 18:48
ThatsAlok7-Sep-05 18:48 
GeneralRe: How does CListCtrl notify its parent window when a cell content has changed? Pin
followait7-Sep-05 20:55
followait7-Sep-05 20:55 
GeneralRe: How does CListCtrl notify its parent window when a cell content has changed? Pin
Frank K7-Sep-05 22:19
Frank K7-Sep-05 22:19 
QuestionA question about compound document and flat document Pin
code_chenyf7-Sep-05 17:29
code_chenyf7-Sep-05 17:29 
Maybe I can not express myself.I mean that I want to develop a ActiveX control container.
Firstly, my document CxxDoc is derived from COleDocument,and the constructor as following:
CxxDoc::CxxDoc()
{
// EnableCompoundFile();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^I need a flat (uncompound) file.

...
}

Is it OK????

Secondly,my client item is CxxClientItem
class CxxClientItem : public COleClientItem

The WriteItem and ReadItem function (copied from the sample program of ActiceX control test container in Visual C++) as follows. They can work correctly in compound document. Please tell me how to change them from compound document to flat(uncompound) document.
void CxxClientItem::WriteItem( CArchive& ar )
{
USES_CONVERSION;
IStoragePtr pStorage;
IStreamPtr pStream;
IPersistStreamInitPtr pPSI;
TCHAR szItemName[64];
HRESULT hResult;
IPersistStoragePtr pPersistStorage;
CxxDoc* pDoc;
CLSID clsid;

(void)ar;

pDoc = GetDocument();
ASSERT_VALID( pDoc );
ASSERT( pDoc->m_lpRootStg != NULL );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT( pDoc->m_bCompoundFile );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT( m_lpStorage != NULL );
ASSERT( !ar.m_bForceFlat );

GetItemName( szItemName );

if( !pDoc->m_bSameAsLoad )
{
hResult = pDoc->m_lpRootStg->CreateStorage( T2COLE( szItemName ),STGM_CREATE|STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE, 0, 0, &pStorage );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
m_lpNewStorage = pStorage;
m_lpNewStorage->AddRef();
m_bNeedCommit = TRUE;
}
else
{
pStorage = m_lpStorage;
}

pPersistStorage = m_lpObject;
if( pPersistStorage != NULL )
{
pPersistStorage->GetClassID( &clsid );
hResult = WriteClassStg( pStorage, clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

hResult = pPersistStorage->Save( pStorage, pDoc->m_bSameAsLoad );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
}
else
{
pPSI = m_lpObject;
if( pPSI == NULL )
{
AfxThrowOleException( E_NOINTERFACE );
}

// Set the storage's CLSID to CLSID_NULL, so we know that we actually
// used a stream
hResult = WriteClassStg( pStorage, CLSID_NULL );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

hResult = pStorage->CreateStream( L"Contents", STGM_CREATE|
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

pPSI->GetClassID( &clsid );
hResult = WriteClassStm( pStream, clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

hResult = pPSI->Save( pStream, TRUE );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

pStream.Release();
}

m_bNeedCommit = TRUE;
pStorage->Commit( STGC_ONLYIFCURRENT );
}

void CxxClientItem::ReadItem( CArchive& ar )
{
USES_CONVERSION;
BOOL tUsedStream;
IStoragePtr pStorage;
IPersistStreamInitPtr pPSI;
IStreamPtr pStream;
TCHAR szItemName[64];
HRESULT hResult;
BOOL tQuickActivated;
IPersistStoragePtr pPersistStorage;
CLSID clsid;

(void)ar;

CxxDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
ASSERT(pDoc->m_lpRootStg != NULL);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document ASSERT(pDoc->m_bCompoundFile);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT(m_lpStorage == NULL);
ASSERT(m_lpLockBytes == NULL);
ASSERT( !ar.m_bForceFlat );

// get item name
GetItemName( szItemName );

// open storage for this item
hResult = pDoc->m_lpRootStg->OpenStorage( T2COLE( szItemName ), NULL,
STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE, 0, 0, &pStorage );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
if( hResult != S_OK )
{
TRACE1( "Warning: unable to open child storage %s.\n", szItemName );
// upon failure throw file exception (item will be cleaned up)
AfxThrowOleException( hResult );
}
ASSERT(pStorage != NULL);

// remember the storage
m_lpStorage = pStorage;
ASSERT(m_lpStorage != NULL);
m_lpStorage->AddRef();

// attempt to load the object from the storage

hResult = ReadClassStg( m_lpStorage, &clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

tUsedStream = FALSE;
if( clsid == CLSID_NULL )
{
hResult = m_lpStorage->OpenStream( L"Contents", NULL, STGM_READ|
STGM_SHARE_EXCLUSIVE, 0, &pStream );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

hResult = ReadClassStm( pStream, &clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}

tUsedStream = TRUE;
}

m_tExtendedControl = TRUE;
hResult = CExtendedControl::CreateInstance( clsid, this, NULL,
IID_IOleObject, (void**)&m_lpObject );
if( FAILED( hResult ) )
{
m_tExtendedControl = FALSE;
// The control may not like being aggregated on, so just try to create it
// directly and punt the extended control stuff.
hResult = CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER|
CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER, IID_IOleObject,
(void**)&m_lpObject );
if( SUCCEEDED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"Could not aggregate on the control, so it won't support extended properties.\n" );
}
}
if( SUCCEEDED( hResult ) )
{
CString strUserType;

GetUserType( USERCLASSTYPE_SHORT, strUserType );
GetDocument()->CreateUniqueItemName( this, strUserType,
m_strDisplayName );
}

if( m_tExtendedControl )
{
m_pExtendedControl = m_lpObject;
ASSERT( m_pExtendedControl != NULL );
m_pExtendedControl->Name = _bstr_t( m_strDisplayName );
}

if( SUCCEEDED( hResult ) )
{
hResult = InitControlInfo();
}

tQuickActivated = FALSE;
if( SUCCEEDED( hResult ) )
{
tQuickActivated = QuickActivate();

if( !tQuickActivated )
{
m_lpObject->GetMiscStatus( DVASPECT_CONTENT, &m_dwMiscStatus );
if( m_dwMiscStatus&OLEMISC_SETCLIENTSITEFIRST )
{
hResult = m_lpObject->SetClientSite( GetClientSite() );
if( FAILED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"SetClientSite failed.\n" );
}
}
}
}

if( SUCCEEDED( hResult ) )
{
pPersistStorage = m_lpObject;
if( pPersistStorage != NULL )
{
hResult = pPersistStorage->Load( m_lpStorage );
}
else
{
if( !tUsedStream )
{
hResult = E_NOINTERFACE;
}
else
{
pPSI = m_lpObject;
if( pPSI == NULL )
{
hResult = E_NOINTERFACE;
}
else
{
hResult = pPSI->Load( pStream );
}
}
}
}

if( SUCCEEDED( hResult ) )
{
if( !tQuickActivated )
{
if( !(m_dwMiscStatus&OLEMISC_SETCLIENTSITEFIRST) )
{
hResult = m_lpObject->SetClientSite( GetClientSite() );
if( FAILED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"SetClientSite failed.\n" );
}
}
}
}

CheckGeneral(hResult);
}


-- modified at 4:04 Thursday 8th September, 2005
QuestionHow to get all the frames of a web page(CHtmlView)? Pin
Tcpip20057-Sep-05 16:48
Tcpip20057-Sep-05 16:48 
AnswerRe: How to get all the frames of a web page(CHtmlView)? Pin
Tcpip20057-Sep-05 16:52
Tcpip20057-Sep-05 16:52 
GeneralRe: How to get all the frames of a web page(CHtmlView)? Pin
Hans Ruck7-Sep-05 20:28
Hans Ruck7-Sep-05 20:28 
GeneralRe: How to get all the frames of a web page(CHtmlView)? Pin
Tcpip20057-Sep-05 20:32
Tcpip20057-Sep-05 20:32 
GeneralRe: How to get all the frames of a web page(CHtmlView)? Pin
Hans Ruck7-Sep-05 20:35
Hans Ruck7-Sep-05 20:35 
AnswerRe: How to get all the frames of a web page(CHtmlView)? Pin
Ralf Martin Hansen3-Apr-24 21:05
Ralf Martin Hansen3-Apr-24 21:05 
QuestionHelp please can someone rewrite this Pin
SummoningDan7-Sep-05 16:33
SummoningDan7-Sep-05 16:33 
AnswerRe: Help please can someone rewrite this Pin
PJ Arends7-Sep-05 16:51
professionalPJ Arends7-Sep-05 16:51 
AnswerRe: Help please can someone rewrite this Pin
Marc Soleda7-Sep-05 20:40
Marc Soleda7-Sep-05 20:40 
QuestionThe PlaySound Function Pin
Mr. Bombastic7-Sep-05 15:30
sussMr. Bombastic7-Sep-05 15:30 
AnswerRe: The PlaySound Function Pin
Christian Graus7-Sep-05 15:42
protectorChristian Graus7-Sep-05 15:42 
QuestionGet a file icon for a given file type... Pin
Ian Bowler7-Sep-05 13:21
Ian Bowler7-Sep-05 13:21 
AnswerRe: Get a file icon for a given file type... Pin
Gary R. Wheeler7-Sep-05 14:32
Gary R. Wheeler7-Sep-05 14:32 
GeneralRe: Get a file icon for a given file type... Pin
Ian Bowler8-Sep-05 7:42
Ian Bowler8-Sep-05 7:42 
AnswerRe: Get a file icon for a given file type... Pin
Graham Bradshaw7-Sep-05 14:33
Graham Bradshaw7-Sep-05 14:33 
GeneralRe: Get a file icon for a given file type... Pin
Ian Bowler8-Sep-05 5:48
Ian Bowler8-Sep-05 5:48 
AnswerRe: Get a file icon for a given file type... Pin
David Crow8-Sep-05 3:22
David Crow8-Sep-05 3:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.