Displaying Multiple Views in IE

Click here for a larger image.

Environment: VC6 Windows 98


This article demonstrates the technique of dynamically creating multiple Views at run-time and opening Web pages on the Views created. The number of views created depends on the list of Web pages saved at the root of the Favourites in your Internet Explorer.

Sometime in 1997, I downloaded some shareware (I don't remember its name); the software had eight views in which you could open sites. At that time, I was a Visual Basic developer and used to be fascinated by these software packages that were probably made with C++ (an alien language for me then), but now that I know a little about VC++, I thought why not try something of this sort and then, if possible, share the code with the Internet community, because of whom I have learnt a lot over the years. In regard to multiple views, I searched all over the MSDN CD (in VS6) and in frustration finally posted my question to a site named ..... and after 15 days got a reply from them, before which I had I managed to get what I wanted to achieve by the trial and error method.

I developed this project after seeing a similar project on this site; it had 6 views (3 columns and 2 rows) and surprisingly there were 6 views of CHTMLView, one for each column. I have tested opening 28 Web pages (4 columns by 7 rows) at a time without any problem.


  • Retrieve all Favourite Sites
  • Stop retrieval of individual sites
  • Stop retrieval of all sites

How to Use the Application

  1. Build the Project.
  2. Exit Visual Studio.
  3. Log on to the Internet.
  4. Go to your favourite sites.
  5. From the Internet Explorer menu option, select Favourites, Add (do not click the Create in >> option).
  6. Save by clicking OK.
  7. Repeat Steps 4-5 until you save all you favourite sites.
  8. Close Internet Explorer (do not log off the Internet).

To use when logged on to the Internet

  1. Start the FavMV application from the Projects Debug folder.
  2. From the menu, select Favourites, Retrieve.
  3. To view individual sites in full-screen mode, first click on the site you want to view in full-screen and then from the menu select View, Full-Screen.
  4. To open a site not in your favourites, select File, Open from the menu.

To use when logged off from the Internet

  1. Start Internet Explorer.
  2. From the menu option, select File, Work Offline.
  3. Minimize Internet Explorer (do not close Internet Explorer).
  4. Start the FavMV application from the Projects Debug folder.
  5. From the menu, select Favourites, Retrieve.

To View in Full-Screen Mode

To view individual sites in full-screen mode, first click on the site you want to view in full-screen and then from the menu select View, Full-Screen.

About the Code

I have embedded the CWebBrowser2 ActiveX control inside the CHTMLView sub-class, which is of type CView and not CHtmlView, because I wanted to display the name of each site on the bar inside each View. I could have used CHtmlView instead.

// To start, we get the location of Favourites folder
// on the system from the Registry in this way
BOOL CMainFrame::getFavouriteskey(TCHAR szPath[MAX_PATH])
  TCHAR           sz[MAX_PATH];
  HKEY            hKey;
  DWORD           dwSize;

  if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\
                User Shell Folders"), &hKey) != ERROR_SUCCESS)
    TRACE0("Favorites folder not found\n");
    return FALSE;
  dwSize = sizeof(sz);
  RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz,
  ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
// Using the returned folder path above, we find the count of the
// number of sites on the Favourites menu option in this way
// Note : The that the file-wide Character Array is filled in this
// member function for later use in the process of retrieving
// the sites
int CMainFrame::GetFavorites(LPCTSTR pszPath, int nStartPos ,
                             CStringArray* caFavourites)


  int nCount = 0;
  CString         strPath(pszPath);
  CString         strPath2;
  CString         str;
  WIN32_FIND_DATA wfd;
  HANDLE          h;
  int             nPos;
  int             nEndPos;
  CStringArray    astrFavorites;
  CStringArray    astrDirs;

  // make sure there's a trailing backslash
  if(strPath[strPath.GetLength() - 1] != _T('\\'))
    strPath += _T('\\');
  strPath2 = strPath;
  strPath += "*.*";

  // now scan the directory, first for .URL files and then for
  // subdirectories that may also contain .URL files

  h = FindFirstFile(strPath, &wfd);
    nEndPos = nStartPos;
      if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|
        str = wfd.cFileName;
        if(str.Right(4) == _T(".url"))

          // an .URL file is formatted just like an .INI file,
          // so we can use GetPrivateProfileString() to get the
          // information we want
                                    _T(""), buf,
                                    strPath2 + str);

          str = str.Mid(0, str.GetLength()-4);
          str = str.Left(str.GetLength() - 4);

          // scan through the array and perform an insertion sort
          // to make sure the menu ends up in alphabetic order
          for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
            if(str.CompareNoCase(astrFavorites[nPos]) < 0)
          astrFavorites.InsertAt(nPos, str);
    } while(FindNextFile(h, &wfd));

  return nCount;
// We now create Views depending on the number of sites
// as returned above, in this way
void CMainFrame::CreateViews(int nRows, int nCols,
                             CCreateContext* pContext)
  int i ,j;
  int iIndex = 0;
  m_Splitter.CreateStatic(this, nRows,nCols);
  for( i = 0 ; i <= nRows-1;i++)
    for( j = 0; j <= nCols-1 ; j++)
      m_Splitter.CreateView(i,j, RUNTIME_CLASS(CMyHTMLView),
                                 CSize(0,0), pContext);


// having created the View we wait for the user to click
// on the menu option "Retrieve"
// we now retrieve each of the sites into the View using the
// character array filled in in the member function
// GetFavorites above
void CMainFrame::OnRetrieve()
  int i,j;
  int nCols = m_Splitter.GetColumnCount();
  int nRows = m_Splitter.GetRowCount();
  int iIndex = 0;
  for( i = 0 ; i <= nRows-1;i++)
    for( j = 0; j <= nCols-1 ; j++)
      CString url = caFavourites.GetAt(iIndex);
      CString siteName = url.Mid(url.Find("//", 0)+2);
      siteName = siteName.Left(siteName.Find("/",0));
      m_wndStatusBar.SetPaneText(0, siteName, TRUE);
      CMyHTMLView* cv = (CMyHTMLView*)m_Splitter.GetPane(i,j);
      // the URL is passed here to the respective
      // sub-class view CMyHTMLView to open the site
      cv->bURLRetrieved = TRUE;


  CRect rect;
  rect.right += 10;
  rect.bottom += 10;
  MoveWindow(rect, TRUE);
  m_wndStatusBar.SetPaneText(0, "", TRUE);
// The method for displaying sites is quite simple as can be
// seen below in the sub-class CHTMLView
// (all the above is in the Mainframe CMainFrame)
void CMyHTMLView::NavigateTheURL(CString url)

  CString siteName = url.Mid(url.Find("//", 0)+2);
  siteName = siteName.Left(siteName.Find("/",0));

  // below is the line for retrieving the site
  m_WebBrowser.Navigate(url, NULL, NULL, NULL, NULL);
  bURLRetrieved = TRUE;


Download demo project - 12 KB
Download source - 34 Kb


  • Is it possible, to exchnage contents of two WebBrowser controls?

    Posted by Legacy on 02/28/2003 12:00am

    Originally posted by: Christian Schildt


    I was looking for a solution of a problem and found your article. Good stuff. Maybe, you can give me some advice?

    I have written an add-in for IE (so called SmartViewers) that extends it with thumb nails functionality. It is a bar left of the IE client area with a number of small browser windows. The links can be dropped into these windows, and the contents is shown zoomed out. Each nail window can be swapped with the main browser. See


    I could not find a better solution for exchanging the contents of two WebBrowsers than simple re-navigation in each of them to URLs of the other. It would be great if the interface IWebBrowser2 had a method like set_Document(IDispatch*).

    Any help will be appriciated.


  • Multiple Views in IE

    Posted by Legacy on 02/19/2003 12:00am

    Originally posted by: Arun

    Thus is quite goood....

  • good

    Posted by Legacy on 02/17/2003 12:00am

    Originally posted by: feng

    see it very good.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date