Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: round a float to int Pin
Christian Graus8-Sep-05 15:44
protectorChristian Graus8-Sep-05 15:44 
GeneralRe: round a float to int Pin
Tim Smith9-Sep-05 3:53
Tim Smith9-Sep-05 3:53 
AnswerRe: round a float to int Pin
Tim Smith9-Sep-05 4:01
Tim Smith9-Sep-05 4:01 
AnswerRe: round a float to int Pin
Tim Smith9-Sep-05 4:26
Tim Smith9-Sep-05 4:26 
Questionsnmp Pin
sebastianos8-Sep-05 15:31
sebastianos8-Sep-05 15:31 
AnswerRe: snmp Pin
David Crow8-Sep-05 16:32
David Crow8-Sep-05 16:32 
AnswerRe: snmp Pin
ThatsAlok8-Sep-05 21:58
ThatsAlok8-Sep-05 21:58 
QuestionActiveX control container, I really need your help Pin
code_chenyf8-Sep-05 14:41
code_chenyf8-Sep-05 14:41 
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 really 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();

......
}

QuestionWM_KEYDOWN Pin
Achim Klein8-Sep-05 14:16
Achim Klein8-Sep-05 14:16 
AnswerRe: WM_KEYDOWN Pin
Christian Graus8-Sep-05 14:22
protectorChristian Graus8-Sep-05 14:22 
GeneralRe: WM_KEYDOWN Pin
Achim Klein8-Sep-05 14:37
Achim Klein8-Sep-05 14:37 
GeneralRe: WM_KEYDOWN Pin
Christian Graus8-Sep-05 14:42
protectorChristian Graus8-Sep-05 14:42 
GeneralRe: WM_KEYDOWN Pin
Achim Klein8-Sep-05 14:49
Achim Klein8-Sep-05 14:49 
GeneralRe: WM_KEYDOWN Pin
Christian Graus8-Sep-05 15:12
protectorChristian Graus8-Sep-05 15:12 
GeneralRe: WM_KEYDOWN Pin
Achim Klein8-Sep-05 15:22
Achim Klein8-Sep-05 15:22 
GeneralRe: WM_KEYDOWN Pin
Christian Graus8-Sep-05 15:25
protectorChristian Graus8-Sep-05 15:25 
GeneralRe: WM_KEYDOWN Pin
Eytukan9-Sep-05 2:09
Eytukan9-Sep-05 2:09 
GeneralRe: WM_KEYDOWN Pin
Achim Klein8-Sep-05 14:50
Achim Klein8-Sep-05 14:50 
General[Message Deleted] Pin
Christian Graus8-Sep-05 15:10
protectorChristian Graus8-Sep-05 15:10 
GeneralRe: WM_KEYDOWN Pin
Tim Smith9-Sep-05 4:11
Tim Smith9-Sep-05 4:11 
Question[Msg Deleted Because Of No Reason] Pin
Eytukan9-Sep-05 1:31
Eytukan9-Sep-05 1:31 
QuestionI am new to this can some1 help me? Pin
Shantise20038-Sep-05 13:26
Shantise20038-Sep-05 13:26 
AnswerRe: I am new to this can some1 help me? Pin
Christian Graus8-Sep-05 13:36
protectorChristian Graus8-Sep-05 13:36 
GeneralRe: I am new to this can some1 help me? Pin
Phil Harding9-Sep-05 14:12
Phil Harding9-Sep-05 14:12 
AnswerRe: I am new to this can some1 help me? Pin
Christian Graus8-Sep-05 16:09
protectorChristian Graus8-Sep-05 16:09 

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.