?
Solved

Windows Explorer

Posted on 2000-05-01
3
Medium Priority
?
331 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 320 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

850 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