by Da1TruEcho » Wed Mar 22, 2017 2:28 pm
class Handler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefResourceHandler,
public CefContextMenuHandler,
public CefJSDialogHandler,
public CefDownloadHandler,
public CefRequestHandler
{
public:
//handler implentation code
private:
CefRefPtr<CefStreamReader> m_pStream;
};
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool Handler::ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
//This function loads the html file into memory
CreateResponseFromResource(theApp.m_hInstance, MAKEINTRESOURCE(IDT_HTMLFILE), &html_content);
m_pStream = CefStreamReader::CreateForData(static_cast<void*>(html_content.GetMemLocation()), html_content.GetSize());
m_streamMimeType = CefString(_T("text/html"));
callback->Continue();
return true;
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool Handler::ReadResponse(void * data_out, int bytes_to_read, int & bytes_read, CefRefPtr<CefCallback> callback)
{
if (!m_pStream)
return false;
DWORD address = DWORD(data_out);
CString output;
bytes_read = m_pStream->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void Handler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
m_pStream = NULL;
}