Directing to a site 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.
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Directing to a site

Post by cyrixware »

Hi just wanna ask what if i want to direct to the website using a single wxButton. After clicking the button it will open the browser and direct it to the specific website. How to do this?

wxHyperlinkCtrl

thanks
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

Handle the EVT_BUTTON event and call wxLaunchDefaultBrowser() with the URL to go to.
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

Can you show me some example? thanks
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

cyrixware wrote:Can you show me some example? thanks

something like this:

Code: Select all

void MyDialog::OnButtonClick()
{
	const wxString url = _T('http://www.google.com');
	wxLaunchDefaultBrowser(&url)
}
not tested,
need to include wx/utils.h
Back to wxWidgets and c++, from long time with php projects
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

yeap i tried

error:

wxLaunchDefaultBrowser : identifier not found, even with the argument dependent lookup.
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

cyrixware wrote:yeap i tried

error:

wxLaunchDefaultBrowser : identifier not found, even with the argument dependent lookup.
do you included wx/utils.h ?
Back to wxWidgets and c++, from long time with php projects
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

yes... but still the only error is that... what should i do next? thanks
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

cyrixware wrote:yes... but still the only error is that... what should i do next? thanks
could you post peace of code ?

btw. you can also use
wxExecute(_T("explorer ") + url, wxEXEC_ASYNC, NULL );
Back to wxWidgets and c++, from long time with php projects
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

i added your code:

Code: Select all

void DialEntryPanel::OnClickButton(wxCommandEvent& event)
{
   thePhoneApp->getFrame().setCallHistoryVisible(! thePhoneApp->getFrame().getCallHistoryVisible());  
   const wxString url = _T("http://www.google.com");
        wxLaunchDefaultBrowser(&url);
}
the only displayed error:

Code: Select all

wxLaunchDefaultBrowser : identifier not found, even with the argument dependent lookup.
also included this

Code: Select all

#include "wx/utils.h"
i try this also

Code: Select all

bool wxLaunchDefaultBrowser(&url);
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

uhh

meybe, ::wxLaunchDefaultBrowser(&url); ?
Back to wxWidgets and c++, from long time with php projects
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

how to use this wxHyperlinkCtrl? thanks
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

cyrixware wrote:how to use this wxHyperlinkCtrl? thanks
wxHyperlinkCtrl is from wxHttpEngine libary
http://wxcode.sourceforge.net/components/wxhttpengine/


try this :P

Code: Select all

void DialEntryPanel::OnClickButton(wxCommandEvent& event)
{
   thePhoneApp->getFrame().setCallHistoryVisible(! thePhoneApp->getFrame().getCallHistoryVisible());  
   const wxString url = _T("http://www.google.com");
        ::wxLaunchDefaultBrowser(&url);
}
Back to wxWidgets and c++, from long time with php projects
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

error: wxLaunchDefaultBrowser is not a member of operator global namespace
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
dsk
Experienced Solver
Experienced Solver
Posts: 91
Joined: Sat Jun 25, 2005 12:10 pm
Location: Poland

Post by dsk »

I have totally no idea here....

you can use
wxExecute(_T("open ") + url, wxEXEC_ASYNC, NULL );
or
wxExecute(_T("explorer ") + url, wxEXEC_ASYNC, NULL );


I saw at sognature that you use wx 2.4.2, meybe its bug there ?
try with 2.6.3

edit:
I tested this
::wxLaunchDefaultBrowser(_T("http://www.google.com"));
and
wxLaunchDefaultBrowser(_T("http://www.google.com"));

both compiled without errors , VC++ 6.0, win 2k, wx 2.6.3
Back to wxWidgets and c++, from long time with php projects
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

Don't use

Code: Select all

wxLaunchDefaultBrowser(&url); 
but

Code: Select all

wxLaunchDefaultBrowser(url); 
The argument is a reference on a string, not a pointer.
Post Reply