Solved

Windows Explorer

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 105
unix example issues 18 100
Excel file not created as expected 7 79
Capture logon name 13 88
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 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