Click here to Skip to main content
15,917,618 members
Home / Discussions / COM
   

COM

 
GeneralRe: activex problems... Pin
rwestgraham16-Sep-05 15:19
rwestgraham16-Sep-05 15:19 
GeneralRe: activex problems... Pin
Jörgen Sigvardsson17-Sep-05 9:31
Jörgen Sigvardsson17-Sep-05 9:31 
GeneralRe: activex problems... Pin
rwestgraham17-Sep-05 12:05
rwestgraham17-Sep-05 12:05 
QuestionNeed help on problem with Excel processes Pin
J. Holzer14-Sep-05 3:44
J. Holzer14-Sep-05 3:44 
QuestionCOM newbie: LNK2005 Pin
Jose M Castellanos12-Sep-05 3:09
Jose M Castellanos12-Sep-05 3:09 
AnswerRe: COM newbie: LNK2005 Pin
Jose M Castellanos13-Sep-05 1:25
Jose M Castellanos13-Sep-05 1:25 
QuestionHow to Show ActiveX Control on a Window? Pin
Ashwin kumar Gurujala11-Sep-05 23:30
Ashwin kumar Gurujala11-Sep-05 23:30 
QuestionActiveX control container Pin
code_chenyf8-Sep-05 14:36
code_chenyf8-Sep-05 14:36 
Friends,
I want to develop a ActiveX control container,and save data in flat(uncompound) document.
My document CxxDoc is derived from COleDocument,and the constructor as following:
CxxDoc::CxxDoc()
{
// EnableCompoundFile();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^I need a flat (uncompound) file.so i delete it.

...
}

Firstly, Is it OK????Can i save data in flat document?

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. I'm a new and I do need your help.Laugh | :laugh:

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;
}

......
}

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();

......
}

QuestionUpdate (Windows) Pin
Illegal Operation8-Sep-05 4:10
Illegal Operation8-Sep-05 4:10 
QuestionSTA & MTA Pin
MailtoGops8-Sep-05 3:07
MailtoGops8-Sep-05 3:07 
QuestionExcel Automation problem Pin
HeartFriend7-Sep-05 20:22
HeartFriend7-Sep-05 20:22 
QuestionCOM and access rights (perhaps ?) Pin
gnilk6-Sep-05 2:17
gnilk6-Sep-05 2:17 
QuestionHow to properly stop STA thread Pin
ComplexLifeForm3-Sep-05 7:19
ComplexLifeForm3-Sep-05 7:19 
QuestionATL Service Pin
Ashwin kumar Gurujala31-Aug-05 21:42
Ashwin kumar Gurujala31-Aug-05 21:42 
AnswerRe: ATL Service Pin
logicaldna31-Aug-05 22:47
logicaldna31-Aug-05 22:47 
QuestionExcel late binding Pin
Anonymous31-Aug-05 21:21
Anonymous31-Aug-05 21:21 
QuestionSOAP quetsion Pin
logicaldna31-Aug-05 19:03
logicaldna31-Aug-05 19:03 
QuestionHow to specify a sound card in windows media player Pin
JaniceA29-Aug-05 23:08
JaniceA29-Aug-05 23:08 
QuestionReally struggling with GetTypeFromProgID Pin
DaveC42691329-Aug-05 8:11
DaveC42691329-Aug-05 8:11 
GeneralRe: Really struggling with GetTypeFromProgID Pin
Jörgen Sigvardsson29-Aug-05 9:00
Jörgen Sigvardsson29-Aug-05 9:00 
GeneralRe: Really struggling with GetTypeFromProgID Pin
DaveC42691329-Aug-05 10:03
DaveC42691329-Aug-05 10:03 
GeneralRe: Really struggling with GetTypeFromProgID Pin
Jörgen Sigvardsson29-Aug-05 19:53
Jörgen Sigvardsson29-Aug-05 19:53 
GeneralRe: Really struggling with GetTypeFromProgID Pin
DaveC42691330-Aug-05 2:59
DaveC42691330-Aug-05 2:59 
QuestionActiveX Control's Bitmaps in ToolBox Pin
Ashwin kumar Gurujala27-Aug-05 1:53
Ashwin kumar Gurujala27-Aug-05 1:53 
GeneralRe: ActiveX Control's Bitmaps in ToolBox Pin
Jörgen Sigvardsson27-Aug-05 13:22
Jörgen Sigvardsson27-Aug-05 13: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.