wxHtmlWindow not working for internet sites Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Acki
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Mar 22, 2008 4:04 pm

wxHtmlWindow not working for internet sites

Post by Acki » Sat Mar 22, 2008 8:36 pm

hi,
I have the problem with the wxHtmlWindow widget...
I posted this before in this thread:
http://forums.wxwidgets.org/viewtopic.p ... l+internet
but mc2r suggested me to create a new thread for this... ;)

and I must say I'm very new to wxWidgets and this is my first attempt to use it... ;)

the wxHtmlWindow widget doesn't connect to the internet, only to local files (sites)...

I always get an error mesage "Unable to open requested HTML documen: {url}" Shocked
and this site definately exist (you can try the URL)...

I have a firewall running and it should ask me if the app shall connect to the internet, but it doesn't !!! Shocked
means it doesn't even try to connect...
even if I disable the firewall completely it doesn't connect...

I'm using:
WinXP pro (sp2)
Code::Blocks (latest nightly) with MinGW/GCC 3.4.5
wxWidgets 2.8.7 (gcc build from wxPack)
I tried with unicode and non unicode DLL (static and monolite not installed)

I used the (in C::B) embeded editor wxSmith and it created this code (I'll post the whole code as far as there's not much in it):

Code: Select all

#include "testMain.h"
#include <wx/msgdlg.h>

//(*InternalHeaders(testFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(testFrame)
const long testFrame::ID_HTMLWINDOW1 = wxNewId();
const long testFrame::idMenuQuit = wxNewId();
const long testFrame::idMenuAbout = wxNewId();
const long testFrame::ID_STATUSBAR1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(testFrame,wxFrame)
    //(*EventTable(testFrame)
    //*)
END_EVENT_TABLE()

testFrame::testFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(testFrame)
    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;
    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxMenu* Menu2;

    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(400,311));
    HtmlWindow1 = new wxHtmlWindow(this, ID_HTMLWINDOW1, wxPoint(208,176), wxDefaultSize, wxHW_SCROLLBAR_AUTO, _T("ID_HTMLWINDOW1"));
    HtmlWindow1->LoadPage(_("http://abusoft.g0dsoft.com/indexold.html"));
    MenuBar1 = new wxMenuBar();
    Menu1 = new wxMenu();
    MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
    Menu1->Append(MenuItem1);
    MenuBar1->Append(Menu1, _("&File"));
    Menu2 = new wxMenu();
    MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
    Menu2->Append(MenuItem2);
    MenuBar1->Append(Menu2, _("Help"));
    SetMenuBar(MenuBar1);
    StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
    int __wxStatusBarWidths_1[1] = { -1 };
    int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
    StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
    StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
    SetStatusBar(StatusBar1);

    Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&testFrame::OnQuit);
    Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&testFrame::OnAbout);
    //*)
}

testFrame::~testFrame()
{
    //(*Destroy(testFrame)
    //*)
}

void testFrame::OnQuit(wxCommandEvent& event)
{
    Close();
}

void testFrame::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}
thx for your attention !!! :)

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 22, 2008 9:50 pm

I also have problem with wxHtmlDCRenderer that work with internet files, when I set path as http://forums.wxwidgets.org/index.php for example, wxWidgets crash on work with sockets when try to load images for page ( text of page loaded successfull ), thats easy to reproduce - just change this rows in wxWidgets\samples\html\printing\printing.cpp( I have add changed file to post ):

void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
{
m_Prn -> PreviewFile( _T("http://forums.wxwidgets.org/index.php") );
}

build sample, run it and select menu item file->preview...

wxWidgets 2.8.7, Win XP, Visual C++ 2005
Attachments
printing.cpp
(8.46 KiB) Downloaded 42 times

mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Re: wxHtmlWindow not working for internet sites

Post by mc2r » Sat Mar 22, 2008 10:04 pm

Code: Select all

testFrame::testFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(testFrame)
    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;
    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxMenu* Menu2;

    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    SetClientSize(wxSize(400,311));

    // Add this here, or in the init for your wxApp
    wxFileSystem::AddHandler(new wxInternetFSHandler);

    HtmlWindow1 = new wxHtmlWindow(this, ID_HTMLWINDOW1, wxPoint(208,176), wxDefaultSize, wxHW_SCROLLBAR_AUTO, _T("ID_HTMLWINDOW1"));
    HtmlWindow1->LoadPage(_("http://abusoft.g0dsoft.com/indexold.html"));

-Max

mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r » Sat Mar 22, 2008 10:12 pm

Lester, you shouldn't tack onto a thread like this, you should rather open a new thread. If the thread you want to add your problem to is relevant you can add a link to it in your post. like you do here...
lester wrote:I also have problem with wxHtmlDCRenderer that work with internet files, when I set path as http://forums.wxwidgets.org/index.php
lester wrote:void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
{
m_Prn -> PreviewFile( _T("http://forums.wxwidgets.org/index.php") );
}
I'm looking at the posted file now, but one note... You should add a wxAssert or an if statement or something to check pointers for NULL'ness when you reference them like this. If m_Prn is NULL when your event is fired your app will crash.

-Max

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 22, 2008 10:17 pm

mc2r wrote:Lester, you shouldn't tack onto a thread like this, you should rather open a new thread. If the thread you want to add your problem to is relevant you can add a link to it in your post. like you do here...
lester wrote:I also have problem with wxHtmlDCRenderer that work with internet files, when I set path as http://forums.wxwidgets.org/index.php
lester wrote:void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
{
m_Prn -> PreviewFile( _T("http://forums.wxwidgets.org/index.php") );
}
I'm looking at the posted file now, but one note... You should add a wxAssert or an if statement or something to check pointers for NULL'ness when you reference them like this. If m_Prn is NULL when your event is fired your app will crash.

-Max
I always use wxASSERT - thats wxWidgets sample, please read my post again, ok - I'll create new topic

mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r » Sat Mar 22, 2008 10:21 pm

lester wrote:
mc2r wrote:Lester, you shouldn't tack onto a thread like this, you should rather open a new thread. If the thread you want to add your problem to is relevant you can add a link to it in your post. like you do here...
lester wrote:I also have problem with wxHtmlDCRenderer that work with internet files, when I set path as http://forums.wxwidgets.org/index.php
lester wrote:void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
{
m_Prn -> PreviewFile( _T("http://forums.wxwidgets.org/index.php") );
}
I'm looking at the posted file now, but one note... You should add a wxAssert or an if statement or something to check pointers for NULL'ness when you reference them like this. If m_Prn is NULL when your event is fired your app will crash.

-Max
I always use wxASSERT - thats wxWidgets sample, please read my post again, ok - I'll create new topic
No, I read it and understood that you used the sample and changed it to what was posted. and what was posted didn't have a wxAssert. So the only question I have is, where is the wxAssert in the code you changed if you ALWAYS USE wxAssert?

-Max

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 22, 2008 10:30 pm

Ohhh, I'd make big mistake - I just change address of loaded file in arguments list, You right - I must clean all sample, samples and even all code in wxWidgets

P.S. please delete my and mc2r offtopic
Last edited by lester on Sat Mar 22, 2008 10:31 pm, edited 1 time in total.

Acki
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Mar 22, 2008 4:04 pm

Re: wxHtmlWindow not working for internet sites

Post by Acki » Sat Mar 22, 2008 10:31 pm

thx very much, Max !!! :)

mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r » Sat Mar 22, 2008 10:40 pm

lester wrote:Ohhh, I'd make big mistake - I just change address of loaded file in arguments list, You right - I must clean all sample, samples and even all code in wxWidgets
All samples and wxWidgets code, no... The piece of the sample that you changed and now causes a crash, YES!!!!! you should add a wxAssert even if the original other of the bit didn't. You see that will help assert that the new path is what is causing the path and not just a bad pointer. It tells us where to look to fix the problem.
lester wrote:P.S. please delete my and mc2r offtopic
Please, don't. Just because you don't see the value doesn't mean some other noob won't.

-Max

Post Reply