Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / Objective C

Fast Binary Tree Operations

Rate me:
Please Sign up or sign in to vote.
4.75/5 (44 votes)
22 Jan 20057 min read 254K   6.1K   107  
Describes main binary tree operations
// 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.


Written By
Software Developer (Senior)
Egypt Egypt

Comments and Discussions