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

Reading and Writing Messages in Outlook Express

, 27 Mar 2006
This article was done to provide an example of IStoreNamespace / IStoreFolder.
/* $Id: DemoDlg.cpp,v 1.3 2005/08/16 17:15:09 pyabo Exp $
 *
 * Author: Pablo Yabo (pablo.yabo@nektra.com)
 *
 * Copyright (c) 2004-2006 Nektra S.A., Buenos Aires, Argentina.
 * All rights reserved.
 *
 * You may modify and/or integrate this code into your commercial software
 * keeping this notice.
 *
 **/

#include "stdafx.h"
#include "Demo.h"
#include "SelectFolderDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSelectFolderDlg dialog


CSelectFolderDlg::CSelectFolderDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSelectFolderDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSelectFolderDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_pStoreNamespace = NULL;
	m_selFolder = -1;
}


void CSelectFolderDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSelectFolderDlg)
	DDX_Control(pDX, IDC_FOLDER_LIST, m_listFolder);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSelectFolderDlg, CDialog)
	//{{AFX_MSG_MAP(CSelectFolderDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelectFolderDlg message handlers

BOOL CSelectFolderDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	AddFolders();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSelectFolderDlg::AddFolders(STOREFOLDERID dwFolderId)
{
	FOLDERPROPS props;
	HENUMSTORE hEnum;
	int nIndex;

	hEnum = NULL;
	props.cbSize = sizeof(FOLDERPROPS);

	HRESULT hr = m_pStoreNamespace->GetFirstSubFolder(dwFolderId, &props, &hEnum);

	while(SUCCEEDED(hr) && hr != S_FALSE && hEnum != NULL) {
		nIndex = m_listFolder.AddString(props.szName);
		if(nIndex != LB_ERR && nIndex != LB_ERRSPACE) {
			m_listFolder.SetItemData(nIndex, props.dwFolderId);
			AddFolders(props.dwFolderId);
		}

		hr = m_pStoreNamespace->GetNextSubFolder(hEnum, &props);
	}

	if(hEnum) {
		m_pStoreNamespace->GetSubFolderClose(hEnum);
	}
}

STOREFOLDERID CSelectFolderDlg::GetSelectedFolderID()
{
	return m_selFolder;
}

void CSelectFolderDlg::OnOK() 
{
	int nIndex;

	// Get selected folder id
	nIndex = m_listFolder.GetCurSel();
	if(nIndex == LB_ERR) {
		MessageBox(_T("Select a folder or cancel."), _T("Demo Error"));
		return;
	}

	m_selFolder = m_listFolder.GetItemData(nIndex);

	CDialog::OnOK();
}

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

Pablo Yabo
Technical Lead http://www.nektra.com
Argentina Argentina
Pablo Yabo is a Software Developer since he was young, specialized in system internals.
In 2003 years ago founded with Sebastian Wain a Company named Nektra specialized in Outlook Express and Outlook Plugin Development.
Now there is a new Windows Live Mail API 2011 / 2009 that works on all the platforms Windows 7, Vista and XP
Follow on   Twitter

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 27 Mar 2006
Article Copyright 2004 by Pablo Yabo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid