Solved

Windows Explorer

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 110
lucky13 challenge 11 122
withoutTen challenge 14 100
Excel file not created as expected 7 50
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. …
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

15 Experts available now in Live!

Get 1:1 Help Now