本文整理汇总了C++中CArchive::Flush方法的典型用法代码示例。如果您正苦于以下问题:C++ CArchive::Flush方法的具体用法?C++ CArchive::Flush怎么用?C++ CArchive::Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArchive
的用法示例。
在下文中一共展示了CArchive::Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnNMClickPlotdataTree
void CControlView::OnNMClickPlotdataTree(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
UpdateData(TRUE);
clicked_flag = TRUE;
CSmartCarDoc * pDoc_temp=(CSmartCarDoc*)m_pDocument;
for (int i=0;i<9;i++)
{
BOOL hehe = m_PlotTree.GetCheck(hPlot[i]);
pDoc_temp->plot[i].SetShowFlag(m_PlotTree.GetCheck(hPlot[i]));
}
//序列化保存配置信息
CFile file (_T ("abc.txt"), CFile::modeCreate | CFile::modeWrite);
CArchive ar (&file, CArchive::store);
for (int i=0;i<9;i++)
{
pDoc_temp->plot[i].Serialize(ar);
}
ar.Flush();
//读完毕,关闭文件流
ar.Close();
file.Close();
*pResult = 0;
}
示例2: Serialize
/*************************************************************************
*
* \函数名称:
* Serialize()
*
* \输入参数:
* CArchive& ar - 指向应用程序归档对象
*
* \返回值:
* 无
*
* \说明:
* 该函数进行串行化过程,将CDib数据进行读入或者写出
*
************************************************************************
*/
void CDib::Serialize(CArchive& ar)
{
DWORD dwPos;
// 获得此归档文件的CFile对象指针
dwPos = ar.GetFile()->GetPosition();
TRACE("CDib::Serialize -- pos = %d\n", dwPos);
// 从归档文件缓冲区中冲掉未写入数据
ar.Flush();
// 重新获得此归档文件的CFile对象指针
dwPos = ar.GetFile()->GetPosition();
TRACE("CDib::Serialize -- pos = %d\n", dwPos);
// 确定归档文件是否被存储,是则进行存储
if(ar.IsStoring()) {
Write(ar.GetFile());
}
// 否则进行加载
else {
Read(ar.GetFile());
}
}
示例3: Write
void CDib::Serialize(CArchive& ar)
{
ar.Flush();
if(ar.IsStoring())
Write(ar.GetFile());
else
Read(ar.GetFile());
}
示例4: Serialize
// DIB is stored as a standard Windows bitmap file
void CDIB::Serialize(CArchive& ar)
{
ar.Flush();
CFile *fp = ar.GetFile();
if (ar.IsStoring()) {
Save(fp);
} else {
Load(fp);
}
}
示例5: LayoutSave
void CSimpleReport::LayoutSave(const char* id, const char* tag)
{
CMemFile memFile;
CArchive ar (&memFile,CArchive::store);
SerializeState(ar);
ar.Flush();
DWORD nBytes = (DWORD)memFile.GetPosition();
LPBYTE pData = memFile.Detach();
AfxGetApp()->WriteProfileBinary(id, tag, pData, nBytes);
ar.Close();
memFile.Close();
free(pData);
}
示例6: Serialize
void CBZDoc::Serialize(CArchive& ar)
{
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
CFile *pFile = ar.GetFile();
ar.Flush();
if (ar.IsLoading()) {
// TODO: add loading code here
m_dwTotal = GetFileLength(pFile);
#ifdef FILE_MAPPING
if(IsFileMapping()) {
if(!MapView()) return;
} else
#endif //FILE_MAPPING
{
if(!(m_pData = (LPBYTE)MemAlloc(m_dwTotal))) {
AfxMessageBox(IDS_ERR_MALLOC);
return;
}
DWORD len = pFile->Read(m_pData, m_dwTotal);
if(len < m_dwTotal) {
AfxMessageBox(IDS_ERR_READFILE);
MemFree(m_pData); // ###1.61
m_pData = NULL;
return;
}
m_bReadOnly = options.bReadOnlyOpen;
}
} else {
// TODO: add storing code here
#ifdef FILE_MAPPING
if(IsFileMapping()) {
BOOL bResult = (m_pMapStart) ? ::FlushViewOfFile(m_pMapStart, m_dwMapSize) : ::FlushViewOfFile(m_pData, m_dwTotal);
if(!bResult) {
ErrorMessageBox();
}
} else
#endif //FILE_MAPPING
pFile->Write(m_pData, m_dwTotal);
m_dwUndoSaved = m_dwUndo; // ###1.54
TouchDoc();
/* if(m_pUndo) {
MemFree(m_pUndo);
m_pUndo = NULL;
}
*/
}
}
示例7: Write
//***************************************************************************************
BOOL CBCGPXMLSettings::Write (LPCTSTR pszKey, CWordArray& wcArray)
{
if (m_bReadOnly)
{
ASSERT (FALSE);
return FALSE;
}
BOOL bRes = FALSE;
try
{
CMemFile file;
{
CArchive ar (&file, CArchive::store);
ar << (int)wcArray.GetSize ();
for (int i = 0; i < wcArray.GetSize (); i ++)
{
ar << wcArray [i];
}
ar.Flush ();
}
#if _MSC_VER >= 1300
ULONGLONG dwDataSize = file.GetLength ();
#else
DWORD dwDataSize = file.GetLength ();
#endif
LPBYTE lpbData = file.Detach ();
if (lpbData == NULL)
{
return FALSE;
}
bRes = Write (pszKey, lpbData, (UINT) dwDataSize);
free (lpbData);
}
catch (CMemoryException* pEx)
{
pEx->Delete ();
TRACE(_T("Memory exception in CBCGPXMLSettings::Write ()!\n"));
return FALSE;
}
return bRes;
}
示例8: Serialize
void CDib::Serialize(CArchive& ar)
{
DWORD dwPos;
dwPos = ar.GetFile()->GetPosition();
TRACE(_T("CDib::Serialize -- pos = %d\n"), dwPos);
ar.Flush();
dwPos = ar.GetFile()->GetPosition();
TRACE(_T("CDib::Serialize -- pos = %d\n"), dwPos);
if(ar.IsStoring()) {
Write(ar.GetFile());
}
else {
Read(ar.GetFile());
}
}
示例9: Serialize
void CSoliDireDoc::Serialize(CArchive& ar)
{
ar.Flush();
CFile* fp = ar.GetFile( );
if (ar.IsStoring())
{
if (is_packed() && IsModified())
pack_added_file(fp);
else
pack_all_file(fp);// pack the file
}
else
{
read_file(fp);
}
}
示例10: OnTvnItemChangedPlotdataTree
void CControlView::OnTvnItemChangedPlotdataTree(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVITEMCHANGE *pNMTVItemChange = reinterpret_cast<NMTVITEMCHANGE*>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
//UpdateData(TRUE);
if (Initial_flag && clicked_flag)//防止bug
{
CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CPlotView* pPlotView_tempt=(CPlotView*)pMain->pPlotView;
CSmartCarDoc * pDoc_temp=(CSmartCarDoc*)m_pDocument;
for (int i=0; i<3; i++)
pPlotView_tempt->Window[i].SetShowFlag(m_PlotTree.GetCheck(hWindow[i]));
for (int i=0;i<9;i++)
pDoc_temp->plot[i].SetShowFlag(m_PlotTree.GetCheck(hPlot[i]));
//序列化保存配置信息
CFile file (_T ("abc.txt"), CFile::modeCreate | CFile::modeWrite);
CArchive ar (&file, CArchive::store);
for (int i=0;i<9;i++)
{
pDoc_temp->plot[i].Serialize(ar);
}
ar.Flush();
//读完毕,关闭文件流
ar.Close();
file.Close();
//保存窗口坐标轴信息
CFile file1 (_T ("Axis.txt"), CFile::modeCreate | CFile::modeWrite);
CArchive ar1 (&file1, CArchive::store);
for (int i=0;i<3;i++)
{
pPlotView_tempt->Window[i].Serialization(ar1);
}
ar1.Flush();
//读完毕,关闭文件流
ar1.Close();
file1.Close();
clicked_flag = FALSE;
//更新视图
pPlotView_tempt->Invalidate(FALSE);
}
*pResult = 0;
}
示例11: SaveState
//************************************************************************************************
BOOL CBCGPMouseManager::SaveState (LPCTSTR lpszProfileName)
{
CString strProfileName = ::BCGPGetRegPath (strMouseProfile, lpszProfileName);
BOOL bResult = FALSE;
try
{
CMemFile file;
{
CArchive ar (&file, CArchive::store);
Serialize (ar);
ar.Flush ();
}
UINT uiDataSize = (UINT) file.GetLength ();
LPBYTE lpbData = file.Detach ();
if (lpbData != NULL)
{
CBCGPRegistrySP regSP;
CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);
if (reg.CreateKey (strProfileName))
{
bResult = reg.Write (strRegEntryName, lpbData, uiDataSize);
}
free (lpbData);
}
}
catch (CMemoryException* pEx)
{
pEx->Delete ();
TRACE(_T("Memory exception in CBCGPMouseManager::SaveState ()!\n"));
}
catch (CArchiveException* pEx)
{
pEx->Delete ();
TRACE(_T("CArchiveException exception in CBCGPMouseManager::SaveState ()!\n"));
}
return bResult;
}
示例12: PacketSerialize
void PacketSerialize(long nPackets, CArchive& arData, CArchive& arAck)
{
BYTE bValue = 0;
WORD nCopies = 0;
if (arData.IsStoring())
{
CString strText;
errno_t err;
unsigned int number;
for(int p = 0; p < nPackets; p++)
{
err = rand_s(&number);
// if (err == 0)...
bValue = (BYTE)(number%256);
err = rand_s(&number);
// if (err == 0)...
nCopies = (WORD)(number%32000);
// Send header information
arData << bValue << nCopies;
for(int c = 0; c < nCopies; c++)
{
// Send data
arData << bValue;
}
strText.Format(_T("Sender sent packet %d of %d (Value = %d, Copies = %d)"),
p + 1, nPackets, (int)bValue, nCopies);
// Send receipt string
arData << strText;
arData.Flush();
// Receive acknowledgment
arAck >> strText;
// display it
DisplayMessage(strText);
}
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:42,代码来源:windows-sockets--example-of-sockets-using-archives_1.cpp
示例13: Write
BOOL CRegistry::Write (LPCTSTR pszKey, CDWordArray& dwcArray)
{
ASSERT (m_hKey != NULL);
ASSERT (pszKey != NULL);
if (m_bReadOnly)
{
ASSERT (FALSE);
return FALSE;
}
BOOL bRes = FALSE;
try
{
CMemFile file;
{
CArchive ar (&file, CArchive::store);
dwcArray.Serialize(ar);
ar.Flush ();
}
DWORD dwDataSize = (DWORD) file.GetLength ();
LPBYTE lpbData = file.Detach ();
if (lpbData == NULL)
{
return FALSE;
}
bRes = Write (pszKey, lpbData, (UINT) dwDataSize);
free (lpbData);
}
catch (CMemoryException* pEx)
{
pEx->Delete ();
TRACE(_T("Memory exception in CRegistry::Write ()!\n"));
return FALSE;
}
return bRes;
}
示例14: _AfxGetArchiveStream
LPSTREAM AFXAPI _AfxGetArchiveStream(CArchive& ar, CArchiveStream& stm)
{
// Obtain direct access to the archive's LPSTREAM.
ar.Flush();
CFile* pFile = ar.GetFile();
ASSERT(pFile != NULL);
LPSTREAM pstm;
if (pFile->IsKindOf(RUNTIME_CLASS(COleStreamFile)))
{
pstm = ((COleStreamFile*)pFile)->m_lpStream;
ASSERT(pstm != NULL);
}
else
{
ASSERT(stm.m_pArchive == NULL || stm.m_pArchive == &ar);
stm.m_pArchive = &ar;
pstm = &stm;
}
return pstm;
}
示例15: Write
BOOL CBCGPRegistry::Write(LPCTSTR pszKey, const CRect& rect)
{
if (m_bReadOnly)
{
ASSERT (FALSE);
return FALSE;
}
BOOL bRes = FALSE;
try
{
CMemFile file;
{
CArchive ar (&file, CArchive::store);
ar << rect;
ar.Flush ();
}
DWORD dwDataSize = (DWORD) file.GetLength ();
LPBYTE lpbData = file.Detach ();
if (lpbData == NULL)
{
return FALSE;
}
bRes = Write (pszKey, lpbData, (UINT) dwDataSize);
free (lpbData);
}
catch (CMemoryException* pEx)
{
pEx->Delete ();
TRACE(_T("Memory exception in CBCGPRegistry::Write ()!\n"));
return FALSE;
}
return bRes;
}