Solved

Windows Explorer

Posted on 2000-05-01
3
315 Views
Last Modified: 2013-11-20
I want to embed a Windows Explorer view inside of a window, much like the the Web Browser ActiveX control.  I want to have the same features as the Windows Explorer, such as dynamic updates.  i.e. if you create a new folder in another Windows Explorer view it appears in my embeded view.  

I tried using the the Web Browser Active X control, which allows you to browse directories, but this did not work.  Each time you click on a folder a new browser is opened.  I tried capturing the NewWindow2 event, but this did not work for directory browsing.
0
Comment
Question by:azmajere
[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
3 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 2767552
When you create a new project in VC++ (at least in v6.0) it asks you whether you want to create an Explorer-type project - this may be a good starting place, since the framework will put alot of what you want in place for you...
0
 

Author Comment

by:azmajere
ID: 2774339
The Explorer type project in VC++ creates a framework for building a Windows Explorer type interface.  It does not provide any of the actual Windows Explorer like features.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 80 total points
ID: 2786687
This turns out to be easier than it looks (But I spent a LOT of time finding that out!)

Insert a WebBrowser Control into your dialog box (or whatever), and add a PreTranslateMessage() handler.  

The main trick is to know that the inner control switches from being a WebBrowser2 into a SysListView32 whenever you navigate to a directory on the local computer.  So when the control's class is "SysListView32", trap the double-click.

I assume that you then want to display that directory (or file) in the same browser window.  So this code gets the current URL, and appends the text of the double-clicked item to that and then Navigates to it.

In the example, I hardcode the starting URL to "C:\" but you may want to have an input bar or some other mechanism.

-=-=-=-=-=-=-=-=-=-=-=-=

BOOL CWbCtrlTesterDlg::OnInitDialog()
{
  CDialog::OnInitDialog();
  m_CtrlBrowser.Navigate("C:\\",0,0,0,0);
  ... etc ...
}

//--------------- probably need a GoBack button since ListView Control
//--------------- right-click does not provide one
void CWbCtrlTesterDlg::OnPbBack()
{
  m_CtrlBrowser.GoBack();      
}

static char gszIEClass[] =       "Internet Explorer_Server";
static char gszListViewClass[] = "SysListView32";

BOOL CWbCtrlTesterDlg::PreTranslateMessage(MSG* pMsg)
{
  //------ note, u could check for Right-click here too (put up your own context menu)
  if ( WM_LBUTTONDBLCLK == pMsg->message ) {
    char szBuf[ 256 ];
    ::GetClassName( pMsg->hwnd, szBuf, sizeof(szBuf) );
    if ( 0 == strcmp(szBuf,gszListViewClass) ) {
      UINT wCnt= ListView_GetSelectedCount(pMsg->hwnd);
      if ( wCnt ) {
        int nItmIdx= ListView_GetNextItem(pMsg->hwnd, -1, LVNI_SELECTED );
        ListView_GetItemText( pMsg->hwnd,nItmIdx, 0, szBuf, , sizeof(szBuf) );
        CString s= m_CtrlBrowser.GetLocationURL();
            if ( s.Right(1) != "/" ) {
                  s += "/";
            }
        s += szBuf;
        m_CtrlBrowser.Navigate(s, 0, 0, 0, 0);
      }
      return( TRUE ); // do no more!
    }
  }
  return CDialog::PreTranslateMessage(pMsg);
}
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 109
Detect CR LF to each line 12 185
sum67 challenge 35 128
sumHeights2  challenge 7 138
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

737 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