Click here to Skip to main content
15,893,594 members
Articles / Desktop Programming / MFC

Thumbnails viewer and image processing using GDI+ and MFC

Rate me:
Please Sign up or sign in to vote.
4.93/5 (78 votes)
24 Sep 20034 min read 372.8K   24.8K   232  
Using GDI+ and MFC to create a thumbnail image viewer and some processing functions
// FoldersDlg.cpp : implementation file
//

#include "stdafx.h"
#include "FoldersDlg.h"
#include "MainFrm.h"
#include "ImageToolDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFoldersDlg dialog
CFoldersDlg::CFoldersDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFoldersDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFoldersDlg)
	//}}AFX_DATA_INIT
}

void CFoldersDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFoldersDlg)
	DDX_Control(pDX, IDC_BROWSE_TREE, m_browseTree);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFoldersDlg, CDialog)
	//{{AFX_MSG_MAP(CFoldersDlg)
	ON_NOTIFY(  TVN_SELCHANGED,    IDC_BROWSE_TREE, OnSelchangedBrowseTree    )
	ON_WM_SIZE(                                                               )
	ON_NOTIFY(  TVN_ITEMEXPANDING, IDC_BROWSE_TREE, OnItemexpandingBrowseTree )
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFoldersDlg message handlers
BOOL CFoldersDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_browseTree.EnableImages();
	m_browseTree.PopulateTree();

	return TRUE;
}

void CFoldersDlg::OnSelchangedBrowseTree(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

	CString sPath; sPath.Empty();
	
	if( m_browseTree.OnFolderSelected( pNMHDR, pResult, sPath ) )
	{
		CImageToolDoc* pDoc=(CImageToolDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument();
		pDoc->SelectFolder( sPath );
	}

	*pResult = 0;
}

void CFoldersDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	if( m_browseTree.m_hWnd != NULL )
	{
		CRect rc; GetClientRect(rc);
		m_browseTree.MoveWindow( rc );
	}
}

void CFoldersDlg::OnItemexpandingBrowseTree(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

	m_browseTree.OnFolderExpanding(pNMHDR,pResult);
	
	*pResult = 0;
}

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


Written By
Software Developer (Senior) IBI Group
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions