Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Fast Binary Tree Operations

, 22 Jan 2005
Describes main binary tree operations.
binarytree_demo.zip
BinaryTreeDemo.exe
binarytree_src.zip
BinaryTreeDemo.dsp
Sample
BinaryTreeDemo.clw
res
BinaryTreeDemo.ico
icon1.ico
icon2.ico
BinaryTreeDemo.dsw
// FolderBrowse.cpp: implementation of the CFolderBrowse class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FolderBrowse.h"
#include <shlobj.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFolderBrowse::CFolderBrowse(HWND hWnd /*= NULL*/)
{
	m_hWnd = hWnd;
}

CFolderBrowse::~CFolderBrowse()
{

}

int CALLBACK BrowseCallbackProc( 
	HWND hwnd, 
	UINT uMsg, 
	LPARAM lParam, 
	LPARAM lpData 
)
{
	switch(uMsg)
	{
		case BFFM_INITIALIZED:
			if(lpData)
				SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpData);
			break;
		case BFFM_SELCHANGED:
			LPITEMIDLIST lpiil = (LPITEMIDLIST)lParam; 
			char szPath[MAX_PATH];
			SHGetPathFromIDList(lpiil, szPath);
			SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szPath);
			break;
	}
	return 0;
}

bool CFolderBrowse::Browse(LPCSTR lpcsInitialFolder /*= NULL*/, LPCSTR lpcsTitle /*= NULL*/)
{
	char szPath[MAX_PATH];

	BROWSEINFO bi;
    bi.hwndOwner = m_hWnd;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = szPath;
    bi.lpszTitle = lpcsTitle ? lpcsTitle : "Select folder";
    bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT;
    bi.lpfn = (BFFCALLBACK)BrowseCallbackProc;
	bi.lParam = (int)lpcsInitialFolder;

	LPITEMIDLIST lpiil = SHBrowseForFolder(&bi);
	if(lpiil == NULL)
		return false;
	SHGetPathFromIDList(lpiil, szPath);
	m_strFolder = szPath;
	
	return true;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author


| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 23 Jan 2005
Article Copyright 2004 by Hatem Mostafa
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid