我正在使用 wxWebView 來顯示我們的頁面內容,當我沒有頁面的任何內容時,即頁面為空白,我看到以下錯誤:

我有我自己的檔案系統處理程式類,從wxWebViewHandler下面和GetFile函式中派生,我設定了頁面的內容。一切正常,除非頁面沒有任何內容。也許我應該回傳其他東西。
struct WxHtmlFSHandler: public wxWebViewHandler
{
WxHtml* dst_;
WxHtmlFSHandler( const wxString& scheme, WxHtml* dst ): wxWebViewHandler( scheme ), dst_( dst )
{ }
wxFSFile* GetFile( const wxString& uri ) override;
~WxHtmlFSHandler()
{
dst_ = nullptr;
}
};
...
if( dst_ && !uri.empty() )
{
if( uri.Contains( dst_->defaultURL_ ) )
{
// load the page's content
//if( !dst_->currentPage_.empty() )
return new wxFSFile( new wxMemoryInputStream( dst_->currentPage_.data(), dst_->currentPage_.size() ),
uri, wxT( "text/html" ), dst_->currentAnchor_
#if wxUSE_DATETIME
, wxDateTime::Now()
#endif
);
...
}
我現在也在使用 IE 引擎。
#if wxUSE_WEBVIEW_IE
wxWebViewIE::MSWSetEmulationLevel( wxWEBVIEWIE_EMU_IE11 );
#endif
我在 Win 10 上使用 wxWidgets 3.1.5。
uj5u.com熱心網友回復:
所以問題是頁面內容為空時。所以我只是嘗試在我的記憶體輸入流中添加一個空格字符,如下所示,看看效果。它似乎作業!
基本上我換了
return new wxFSFile( new wxMemoryInputStream( "", 0 ),
uri, wxT( "text/html" ), dst_->currentAnchor_
#if wxUSE_DATETIME
, wxDateTime::Now()
#endif
);
和
return new wxFSFile( new wxMemoryInputStream( " ", 1 ),
uri, wxT( "text/html" ), dst_->currentAnchor_
#if wxUSE_DATETIME
, wxDateTime::Now()
#endif
);
現在頁面是空白的,沒有按預期顯示任何內容。我不知道這個hack是否好,甚至正確,所以如果有人有更好的答案,請告訴我。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/512484.html
