Click here to Skip to main content
15,892,697 members
Articles / Desktop Programming / MFC

Customizing the Windows Common File Open Dialog

Rate me:
Please Sign up or sign in to vote.
4.44/5 (15 votes)
19 Nov 19999 min read 379K   3.3K   104  
//-------------------------------------------------------------------------------------------

// Customized version of the File Open common dialog
// Copyright (C) 1999 by Shanker.C
// All rights reserved
// Author's consent required if this program is to be used for commercial purposes
// No warranty of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the user.
// For a full description of the code, see associated documentation.
// Please send comments/suggestions/criticisms to: Shanker@xlprint.com
// November 3, 1999

//-------------------------------------------------------------------------------------------

#include "QuickLaunch.h"
#include "customfiledlg.h"
#include <direct.h>
#include <afxcoll.h>

//-------------------------------------------------------------------------------------------

using namespace NSPCUSTOMDLG;

//-------------------------------------------------------------------------------------------

CQuickLaunchApp :: InitInstance()
{
	m_pMainWnd = new CQuickWnd;
	m_pMainWnd -> ShowWindow(SW_NORMAL);
	m_pMainWnd -> UpdateWindow();
	return TRUE;
}

//-------------------------------------------------------------------------------------------

CQuickWnd :: CQuickWnd()
{
	CreateEx(WS_EX_ACCEPTFILES, NULL, "Power Subclassing", WS_OVERLAPPEDWINDOW, 
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL);
}

//-------------------------------------------------------------------------------------------

BEGIN_MESSAGE_MAP(CQuickWnd, CFrameWnd)

	ON_WM_LBUTTONDOWN()
	ON_WM_PAINT()
		
END_MESSAGE_MAP()

//-------------------------------------------------------------------------------------------

void CQuickWnd :: OnLButtonDown(UINT flags, CPoint point)
{
	TCHAR szPath[MAX_CHAR];

	ZeroMemory(szPath, MAX_CHAR);
	GetWindowsDirectory(szPath, MAX_CHAR);
	CStringList* list = getFileNames(szPath, "All Files\0*.*\0"); 
	
	POSITION pos;
	if(list)
	{
		for(pos = list -> GetHeadPosition(); pos != NULL; list -> GetNext(pos))   
			AfxMessageBox(list ->GetAt(pos));
	}

	delete list;
}

//-------------------------------------------------------------------------------------------

void CQuickWnd :: OnPaint()
{
	CPaintDC dc(this);
	CRect rect;
	GetClientRect(&rect);

	dc.SetTextColor(RGB(255, 0, 0));
	dc.DrawText("Left click for demo...",-1, &rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}

//-------------------------------------------------------------------------------------------

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
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions