Note that there are some explanatory texts on larger screens.

plurals
  1. POFilling window with a wxWebView
    primarykey
    data
    text
    <p>I would like to fill an application window created with wxWidgets with a wxWebView. After reviewing the wxWebView sample, there the author created a wxFrame which then contained a wxBoxSizer and a wxWebView was added directly to that. However I would like my application to use a wxSingleChoiceDialog, so as far as I can tell, that means I need to include something like a wxPanel to use as the dialog's parent (the first argument to the constructor is the 'parent' of type wxWindow). So in my application I put a wxPanel in the wxFrame and then set the wxBoxSizer of the wxPanel to include the wxWebView. Unfortunately now the wxWebView no longer fits the full application window and I'm not sure why. Here is a simplified example of the application I'm trying to create.</p> <p>main.h</p> <pre><code>#ifndef MAIN_H #define MAIN_H #include &lt;wx/wx.h&gt; class MyApp : public wxApp { public: virtual bool OnInit(); }; DECLARE_APP(MyApp) #endif </code></pre> <p>main.cpp</p> <pre><code>#include "main.h" #include "mainframe.h" IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { MainFrame *mainFrame = new MainFrame(wxT("Content Creator")); mainFrame-&gt;Show(true); return true; } </code></pre> <p>mainframe.h</p> <pre><code>#ifndef MAINFRAME_H #define MAINFRAME_H #include &lt;wx/wx.h&gt; #include &lt;wx/webview.h&gt; class MainFrame : public wxFrame { public: wxPanel *panel; wxBoxSizer *topsizer; wxMenuBar *menubar; wxMenu *file; wxWebView *webView; wxString editorURL; MainFrame(const wxString&amp; title); void initMenu(); void initEditor(); }; #endif </code></pre> <p>mainframe.cpp</p> <pre><code>#include "mainframe.h" MainFrame::MainFrame(const wxString&amp; title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800,600)) { panel = new wxPanel(this, -1); topsizer = new wxBoxSizer(wxVERTICAL); panel-&gt;SetSizer(topsizer); initMenu(); initEditor(); } void MainFrame::initMenu() { menubar = new wxMenuBar; file = new wxMenu; //file-&gt;Append(wxID_EXIT, wxT("Quit")); menubar-&gt;Append(file, wxT("File")); SetMenuBar(menubar); } void MainFrame::initEditor() { editorURL = "file:///C:/Users/kenwood/Desktop/MarkCreator2/ckeditor/samples/editor.html"; webView = wxWebView::New(panel, wxID_ANY, editorURL); topsizer-&gt;Add(webView, 1, wxEXPAND | wxALL, 0); } </code></pre> <p>Here is a screenshot of the application this creates: <a href="http://s10.postimg.org/ronnxfsyx/screenshot.jpg" rel="nofollow">Screenshot</a></p> <p>Does anyone know how I might be able to make this wxWebView fill the application window (or at least why it isn't fitting the window because I'm clearly missing something here)? I realize I can create a wxWebView an specify a a size that would be equal to the window size, but then when the user resizes the screen webview is no longer the same size as the application window.</p> <p>Thanks.</p> <p>EDIT:</p> <p>Also, I'm using wxWidgets version 2.9.4</p> <p>EDIT 2:</p> <p>It appears that calling initEditor() before initMenu() produces the desired result (but not the other way around). Would anyone know what the reason for this is? I would really like to call initMenu() first if that is possible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload