Dialog tutorial:
Part 5 Building a HTML viewer
This page builds a simple HTML viewer
with buttons for Home, forwards and backwards
Start a new dialog project in
the wHatch main menu, eg html_vew.
- Add a HTML window by selecting
CreateButtonSizer and then add a wxStaticLine (try the toolbar - click
) and then
a wxHtmlWindow 
- To get a toolbar-like row of buttons
along the top select the mainsizer, and add a wxBoxsizer called
toolsizer
Change its
properties to wxHORIZONTAL
- Add a home button by selecting
m_boxsizer and clicking
. Call the control homebutton. This adds the
button and an event handler to the code
- go to the include file and modify
the code:
html_vew dialog(this, wxT("my
HTML"));
dialog.m_HtmlWindow_LoadPage ( /* const
wxString& */ wxT( "index.html" ) );
dialog.homebutton_SetLabel ( /* const
wxString&
*/ wxT( "home" ) );
- goto the bottom of the dialog's cpp
file and find the event handler and add a line to show the home page
when the button is clicked:
void html_vew::OnhomebuttonEvent ( wxCommandEvent &
event )
{
m_HtmlWindow -> LoadPage(wxT( "index.html"
) );
};
- Use your favourite HTML
editor to create a HTML test page, and save it as index.html
- Compile and run
- Watch how the dialog changes if you
try and resize it. To make the HTML window grow more than the other
controls, change the zero to a 4 in the line [this may be done in
the editor in a wxhatch version > 1.3]
mainsizer -> Add(m_HtmlWindow, 0, wxALL | wxEXPAND,
5);
- Optional extra: in the event
handler, double click event and use Insert Code | Surround selection |
wxUnused to abolish the warning with Watcom (and other compilers that
report unused variables as warnings)
Next
Back
wxHatch
Home 