資源簡介
code project大神寫的在MFC中嵌入cef瀏覽器demo
具有較大參考 價值

代碼片段和文件信息
//?CefDoc.cpp?:?implementation?of?the?CefDoc?class
//
#include?“stdafx.h“
//?SHARED_HANDLERS?can?be?defined?in?an?ATL?project?implementing?preview?thumbnail
//?and?search?filter?handlers?and?allows?sharing?of?document?code?with?that?project.
#ifndef?SHARED_HANDLERS
#include?“cefmfcdemo.h“
#endif
#include?“CefDoc.h“
#include?
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#endif
//?CefDoc
IMPLEMENT_DYNCREATE(CefDoc?CDocument)
BEGIN_MESSAGE_MAP(CefDoc?CDocument)
END_MESSAGE_MAP()
//?CefDoc?construction/destruction
CefDoc::CefDoc()
{
//?TODO:?add?one-time?construction?code?here
}
CefDoc::~CefDoc()
{
}
BOOL?CefDoc::OnNewDocument()
{
if?(!CDocument::OnNewDocument())
return?FALSE;
//?TODO:?add?reinitialization?code?here
//?(SDI?documents?will?reuse?this?document)
return?TRUE;
}
//?CefDoc?serialization
void?CefDoc::Serialize(CArchive&?ar)
{
if?(ar.IsStoring())
{
//?TODO:?add?storing?code?here
}
else
{
//?TODO:?add?loading?code?here
}
}
#ifdef?SHARED_HANDLERS
//?Support?for?thumbnails
void?CefDoc::OnDrawThumbnail(CDC&?dc?LPRECT?lprcBounds)
{
//?Modify?this?code?to?draw?the?document‘s?data
dc.FillSolidRect(lprcBounds?RGB(255?255?255));
CString?strText?=?_T(“TODO:?implement?thumbnail?drawing?here“);
LOGFONT?lf;
CFont*?pDefaultGUIFont?=?CFont::FromHandle((HFONT)?GetStockobject(DEFAULT_GUI_FONT));
pDefaultGUIFont->GetLogFont(&lf);
lf.lfHeight?=?36;
CFont?fontDraw;
fontDraw.CreateFontIndirect(&lf);
CFont*?pOldFont?=?dc.Selectobject(&fontDraw);
dc.DrawText(strText?lprcBounds?DT_CENTER?|?DT_WORDBREAK);
dc.Selectobject(pOldFont);
}
//?Support?for?Search?Handlers
void?CefDoc::InitializeSearchContent()
{
CString?strSearchContent;
//?Set?search?contents?from?document‘s?data.?
//?The?content?parts?should?be?separated?by?“;“
//?For?example:??strSearchContent?=?_T(“point;rectangle;circle;ole?object;“);
SetSearchContent(strSearchContent);
}
void?CefDoc::SetSearchContent(const?CString&?value)
{
if?(value.IsEmpty())
{
RemoveChunk(PKEY_Search_Contents.fmtid?PKEY_Search_Contents.pid);
}
else
{
CMFCFilterChunkValueImpl?*pChunk?=?NULL;
ATLTRY(pChunk?=?new?CMFCFilterChunkValueImpl);
if?(pChunk?!=?NULL)
{
pChunk->SetTextValue(PKEY_Search_Contents?value?CHUNK_TEXT);
SetChunkValue(pChunk);
}
}
}
#endif?//?SHARED_HANDLERS
//?CefDoc?diagnostics
#ifdef?_DEBUG
void?CefDoc::AssertValid()?const
{
CDocument::AssertValid();
}
void?CefDoc::Dump(CDumpContext&?dc)?const
{
CDocument::Dump(dc);
}
#endif?//_DEBUG
//?CefDoc?commands
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-06-09?04:43??cefmfcdemo\
?????文件????????2674??2016-05-17?19:46??cefmfcdemo\CefDoc.cpp
?????文件?????????911??2016-05-17?19:46??cefmfcdemo\CefDoc.h
?????文件????????5249??2016-05-18?22:03??cefmfcdemo\cefmfcdemo.cpp
?????文件?????????791??2016-05-18?22:03??cefmfcdemo\cefmfcdemo.h
?????文件???????10428??2016-05-19?15:54??cefmfcdemo\cefmfcdemo.rc
?????文件???????12374??2016-05-21?05:23??cefmfcdemo\cefmfcdemo.vcxproj
?????文件????????3162??2016-05-18?19:03??cefmfcdemo\cefmfcdemo.vcxproj.filters
?????文件????????5700??2016-06-09?04:43??cefmfcdemo\CefView.cpp
?????文件????????2254??2016-06-09?04:42??cefmfcdemo\CefView.h
?????文件????????3452??2016-05-18?05:15??cefmfcdemo\CefWindowsHelpers.cpp
?????文件?????????588??2016-05-18?05:08??cefmfcdemo\CefWindowsHelpers.h
?????文件????????2922??2016-06-05?05:39??cefmfcdemo\ClientHandler.cpp
?????文件????????3510??2016-06-05?05:32??cefmfcdemo\ClientHandler.h
?????目錄???????????0??2016-05-18?22:06??cefmfcdemo\html\
?????文件????????1247??2016-05-19?05:54??cefmfcdemo\html\index.html
?????文件????????4607??2016-05-19?16:14??cefmfcdemo\MainFrm.cpp
?????文件????????1076??2016-05-19?16:13??cefmfcdemo\MainFrm.h
?????文件??????????92??2016-05-18?19:02??cefmfcdemo\MainToolbar.h
?????文件????????5237??2016-05-17?19:46??cefmfcdemo\ReadMe.txt
?????目錄???????????0??2016-05-17?19:46??cefmfcdemo\res\
?????文件?????????868??2016-05-18?19:07??cefmfcdemo\Resource.h
?????文件???????67777??2013-07-22?06:18??cefmfcdemo\res\cefmfcdemo.ico
?????文件?????????804??2016-05-18?16:07??cefmfcdemo\res\cefmfcdemo.rc2
?????文件????????4710??2013-07-22?06:18??cefmfcdemo\res\cefmfcdemoDoc.ico
?????文件?????????598??2016-05-18?16:27??cefmfcdemo\res\Toolbar.bmp
?????文件?????????212??2016-05-17?19:46??cefmfcdemo\stdafx.cpp
?????文件????????1753??2016-05-17?19:46??cefmfcdemo\stdafx.h
?????文件?????????314??2016-05-17?19:46??cefmfcdemo\targetver.h
評論
共有 條評論