Solved

Windows Explorer

Posted on 2000-05-01
3
296 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now