Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Load Web URL

Posted on 2001-06-11
10
Medium Priority
?
262 Views
Last Modified: 2013-11-20
I need to load a web page programatically. I set up a dynamic menu sort of like a favorites for an application. I tried ShellExecute but it is only working for local web pages, it isn't finding urls (like www.hotmail.com). I tried OpenURL but the link to the documentation from the index in my msdn is broken for some reason, so I can't read the documentation. I tried using openurl through cinternetsession, but I couldn't figure how to make it work. Does anyone know a simple function like

 GotoInDefaultBrowser(CString url)
0
Comment
Question by:tvanceplus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 6179512
'ShellExecute()' does work for any URL - were you online when testing this?
0
 

Expert Comment

by:SrinivasaRao
ID: 6179944
Are you working with Document/view architecture?
If so and do not have problems in using CHtmlView you can use it.Read MSDN documentation for more details.
BSR
0
 

Expert Comment

by:ravi_pvkumar
ID: 6180110

Hi,

//// this program is to get the content of the Web page requested.

declare m_Out,m_host,  as member variable of EditBox with type as string.

OnQuery is ON_BN_CLICK

OnQuery()
{
    const CString http = "http://";
    UpdateData(TRUE);
    m_Out = "";
    UpdateData(FALSE);
    TryURL(http + m_host);
    TryURL(http + "www." + m_host);

}




TryURL(CString URL)
{
 
 CInternetSession session;
  m_Out += "Trying " + URL + "\r\n";
  UpdateData(FALSE);
  CInternetFile* file = NULL;
   try
   {
        //We know for sure this is an Internet file,
          //so the cast is safe
          file = (CInternetFile*) session.OpenURL(URL);
   }// end of try
     catch (CInternetException* pEx)
     {
          //if anything went wrong, just set file to NULL
          file = NULL;
          pEx->Delete();
     } // end of catch
     if (file)
     {
          m_Out += "Connection established. \r\n";
          CString line;
for (int i=0; i < 20 && file->ReadString(line);i++)
{
               m_Out += line + "\r\n";
}
          file->Close();
          delete file;
     }
     else
     {
          m_Out += "No server found there. \r\n";
     }
     m_Out += "------------------------\r\n";
     UpdateData(FALSE);


}


if you want page to be displayed then go for AppWizard and in last step take help of htmlview
then in the function OnInitialUpdate
use the function named :      
Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);

you can chage the url and navigate dynamically with your program
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Assisted Solution

by:MadYugoslav
MadYugoslav earned 200 total points
ID: 6180422
Be sure that URL You specified sutisfy URL rules.
Try to specify protocol for open URL for example:

ShellExecute(m_hWnd, "open", "http://www.hotmail.com", NULL, NULL, SW_SHOWNORMAL);

What mean before You call ShellExecute You correct You URL string to start with protocol name gor browsing:
http://, ftp://, gopher://, and so on.
0
 
LVL 1

Author Comment

by:tvanceplus
ID: 6189324
I've tried ShellExecute several times. It isn't working. I tried the CInternetSession thing that you guys posted. That didn't work either. I am connected on a DSL through a proxy server. Could that screw the process up somehow? I am desperate (raising points) This product went to beta testing last week. I had a routine that searches the directory system for iexplore.exe, but I would really like it if I could use the default browser.
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189679
I must repeat my last posted comment.
If it doesn't work please post URL You want to load (just for checking my solution).
0
 
LVL 1

Author Comment

by:tvanceplus
ID: 6196862
http://teambse.com
http://www.builders-software.com

try these

if they work, post again
0
 

Expert Comment

by:SrinivasaRao
ID: 6197513
Have you troed one suggested by ravi_pvkumar. I think it will be working for you.
BSR
0
 
LVL 1

Expert Comment

by:jizhang
ID: 6202620

I think use ShellExecute(...,"open","http://..."...) should work,
if you have set  your default web browser in your system
(or set web file type in Windows-Explorer->View->options->File type)

You need to fill right m_hWnd, for example, if I want to access the
web site when I display About Box:

void CA07App::OnAppAbout()
{
     CAboutDlg aboutDlg;
     aboutDlg.DoModal();
     ShellExecute(AfxGetApp()->m_pMainWnd->m_hWnd, _T("open"),                  _T("http://www.builders-software.com"), NULL, NULL, SW_SHOWNORMAL);

}

where I use AfxGetApp()->m_pMainWnd->m_hWnd to get m_hWnd.
I use _T("..."), because I compiled with _UNICODE option.

Another way is use ShellExecute() to run a .exe (netscape or IE executable)
and fill parameters in 4th arg:

ShellExecute
(m_hWnd,"open","C:\\netscape\\program\\netscape.exe","http://my_prox//my_target//index.html",....)
in 4th arg, fill out with the URL string format you used to use when access outside
web page.



0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9484624
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : jkr, MadYugoslav (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question